How can I make a 3d plot using 2 functions combined in 1 function?
7 views (last 30 days)
Show older comments
Hi friends! I have the following problem.
I have written two separate functions with two separate input arguments: function1 with input argument x and function2 with input argument y. The two functions symbolise the profit of option 1 and 2.
In a new function I have combined function1 and function2 in just 1 function. The name of the function is total_return and sums the profit of function1 and 2. In the new function the profit of function1 is multiplied with a and the profit of function 2 is multiplied with 1-a. The new function therefore has the input arguments: a, x and y.
I would like to make a 3d plot (surf) with the variables: a, x and total_return.
So that makes:
surf(a,x,total_return(a,x,8.5)).
1: let's say, we make the last input variable of the total_return function 8.5 (=y).
2: in the workspace I have made a row vector of x (1x100) and a column vector of a (100x1).
When I compute the surf function I still get:
error using +
matrix dimensions must agree.
-->Referring to the part of the new function were I sum up the two profits in 1 profit, that 1 profit being: total_return. Something is clearly wrong here, but I can't figure it out.
I thinks something goes wrong with the computation of the two separate functions, those dimensions don't agree or something.
I would love to have some help with this. Thank you very much in advance. I am chemical student and struggling at the moment. I hope this explanation is elaborate enough for you. I am using matlab r2012b
Thanks,
Tjeerd
Entire function:
function [ total_return ] = total_return ( a,x,y ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here
h2_price = x;
cog_volumein = 12800;
cog_lhv = 18.39;
cog_energy_inlet = ((cog_lhv * cog_volumein)/1000);
loadfactor = 8500;
psa_eff = 0.775;
h2_contentcog = 0.59656;
h2_density = 0.0899;
h2_vfrexit = cog_volumein * psa_eff * h2_contentcog;
h2_mfrexit = h2_vfrexit * h2_density;
h2_lhv = 120;
h2_energy = h2_lhv * h2_mfrexit * loadfactor;
h2_value = h2_price * h2_mfrexit * loadfactor;
cog_volumeexit = cog_volumein-h2_vfrexit;
cog2_lhv = 25.16;
cog_energy_exitPSA = cog_volumeexit * cog2_lhv/1000;
elec_eff = 0.39;
cog_elecprod = cog_energy_exitPSA * elec_eff/3.6;
elec_price = 50.50;
cog_elprod_value = elec_price * cog_elecprod * loadfactor;
cog_price = 5.4;
cog_cost = cog_price * cog_energy_inlet * loadfactor;
h2_return = h2_value + cog_elprod_value - cog_cost;
wb2_value = cog_energy_inlet * y * loadfactor;
cog_cost = cog_price * cog_energy_inlet * loadfactor;
wb2_return = wb2_value - cog_cost;
return1 = a * h2_return;
return2 = (1 - a) * wb2_return;
total_return = return1 + return2;
end
Falling line:
total_return = return1 + return2;
2 Comments
Jan
on 4 Jan 2014
Edited: Image Analyst
on 4 Jan 2014
Please show us the failing line and the dimensions of the variables. The debugger will help you to find them out.
Answers (0)
See Also
Categories
Find more on Line Plots 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!