How do you evaluate a revenue function over a range of price and quanity inputs?

12 views (last 30 days)
Problem: I have generated a production function which yields a production quantity qm_30 (m x n matrix) for months 1:length(qm_30). I used the ndgrid Matlab function to evaluate my production function over a range of inputs, but can't figure out how to (if I can) use it to evaluate the formula below over a range of the variable price .
Question: How can I solve most efficiently for netcfq given a range of input values for the variable price ?
  • qm_30 is a 487 x 11 (m x n) matrix
  • all other variables are scalars
  • price is currently a scalar ($4.00) but I would like to set it to be a range (say $3.00:0.50:$5.00)
  • netcfq = (qm_30*nri*( price +pricediff))-(qm_30* price *prodtax)-(qm_30*opex_var)-((qm_30./qm_30)*opex_fix);
Thanks!

Answers (1)

dpb
dpb on 9 Jul 2014
Edited: dpb on 9 Jul 2014
Factoring out the common variable of qm30, it would seem your functional is--
netcfq = qm_30*(nri*(price+pricediff) - price*prodtax - opex_var) - opex_fix;
To evaluate over an array, simply convert to use the "dot" operators--
netcfq = qm_30.*(nri.*(price+pricediff) - price.*prodtax - opex_var) - opex_fix;
Should be all need unless I missed something. Generate the array w/ meshgrid per the example therein--
doc meshgrid
  6 Comments
dpb
dpb on 9 Jul 2014
Oh...my misunderstanding...think your best bet in this case is simply to write a loop, likely.
txvmi07
txvmi07 on 10 Jul 2014
Edited: txvmi07 on 10 Jul 2014
Thanks...I kept trying it with 3D matrices and reshaping and while it would execute the output was sort of perplexing and not logical. I'm now trying to use a loop to iterate my price input range (pr) over the production quantity (qm_30) to calculate netcfq and then be able to do subsequent operations with that number. I keep getting an error with the loop, code is below. I believe I may need another for loop included perhaps so that the function iterates over the range of price for every column in qm_30 (487x11 matrix), but I'm not sure.
% Financial Calculations - Price range
pr = 3.00:0.50:5.00; % PRICE RANGE TO ITERATE OVER
pvq_pr = zeros(size(pr,2),size(qm_30,2));
payout_pr = zeros(size(pr,2),size(qm_30,2));
for ii = 1:size(pr,1)
netcfq_pr = qm_30.*(nri.*(pr(ii)+pricediff) - pr(ii).*prodtax - opex_var) - opex_fix; % NET CASH FLOW FUNCTION
netcfq_or(isnan(netcfq_pr))=0; % Remove NaN and treat as zeros
netcfq_ec_pr = netcfq_pr.*(netcfq_pr>0); % Test if economic and create variable of only montly cash flows that are positive
cfq_pr = [-wellcost_row; netcfq_ec_pr];
netcfcumq_pr = cumsum(cfq_pr);
pvq_pr(ii) = pvvar(cfq_pr,disc_rate/12);
payout_pr(ii) = sum(netcfcumq_pr<0);
end

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!