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

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!

Réponses (1)

dpb
dpb le 9 Juil 2014
Modifié(e) : dpb le 9 Juil 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 commentaires

Thanks, but I'm having a little trouble with using the meshgrid function to accomplish this. I've created a variable containing the price range I'd like to iterate over, P2 = 3.0:0.5:5.0 (1 x 5). Given the qm_30 variable is 487x11, when I use meshgrid on P2 and qm_30 I'm not getting the output I'm looking for, it's just stacking the qm_30 values together, creating a 5357x5 variable. What am I doing wrong?
I've uploaded the qm_30 fule I've referenced if you'd like to take a look. Like I said, I'm not sure exactly where I'm going wrong but would appreciate any insight you can offer.
I was presuming qm_30 was generated by meshgrid(x,y) where the x and y are the two variables over which the evaluation was wanted. To add a 3rd dimension, the extension would be meshgrid(x,y,z) where z is the price level vector.
If that's not the correct assumption, we'll have to dig deeper...
qm_30 is the output of a function I wrote which generates production values for a hybrid curve which is both hyperbolic and exponential (representing natural gas production from a well). So with., qm_30 solved for, I am then trying to assess the economic viability of the separate well cases (each column in qm_30) by calculating netcfq (monthly net cash flow) given qm_30, commodity price (price), and certain costs (production taxes, variable operating expenses, and fixed operating expenses).
Calculating netcfq for one (scalar) price was easy, but when I wanted to calculate what netcfq for price = $3.00:0.50:$5.00 I ran into trouble.
So...if I could do it correctly, I think I'd end up with a (5 x 11 x 487) matrix given the 5 prices, 11 production cases, and 487 months.
Thank you again! If I can clarify any further please let me know.
Oh...my misunderstanding...think your best bet in this case is simply to write a loop, likely.
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

Connectez-vous pour commenter.

Question posée :

le 9 Juil 2014

Modifié(e) :

le 10 Juil 2014

Community Treasure Hunt

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

Start Hunting!

Translated by