too many output arguments, ploting loop function

1 view (last 30 days)
Hi, I need completely help. I want to plot kind of 3D function with loop based on following codes (it's cut off so I dont copied all)
So, basically I want to plot x,y,z (lifetime,efficiency,H2MSAeff) from the function H2MSA_conversion.m . That function hat the head
function [H2MSA_eff]=H2MSA_conversion(senslife,eta,msaprice).
But I got error message :
Error using H2MSA_conversion
Too many output arguments.
Error in H2MSAeff_basecase_plot (line 87)
[a,b]=H2MSA_conversion(lifetime(j),efficiency(i), msaprice);
The codes I use for ploting:
%sensitivity analysis
%lifetime and efficiency
lifetime=linspace(30,5,20);
efficiency=linspace(0.3,0.05,20);
l=length(lifetime);
e=length(efficiency);
H2MSAeff=zeros(l,e); %EMPHASIS
for i=1:e
for j=1:l
[a,b]=H2MSA_conversion(lifetime(j),efficiency(i), msaprice); %EMPHASIS
plot_H2MSA_conversion=[a,b];
H2MSAeff(i,j)=plot_H2MSA_conversion(key);
end
end
Unrecognized function or variable 'msaprice'.
efficiency=efficiency*100;
[Lifetime,Efficiency,H2MSAeff]=griddata(lifetime,efficiency,H2MSAeff,linspace(min(lifetime),...
max(lifetime),100)',linspace(min(efficiency),max(efficiency),100),'linear');
if figurekey==1
Lmin=min(min(H2MSAeff));Lmax=max(max(H2MSAeff));
L=[Lmin,100,1000,10000,30000,40000,Lmax];
L=roundn(L,-1);
[C,h]=contourf(Lifetime,Efficiency,H2MSAeff,L,'ShowText','on','color','white');
clabel(C,h,'FontSize',13,'Color','w'); %Set curve label font size
colorbar;
colormap(parula);
xlabel('Lifetime(year)');
ylabel('STH Efficiency(%)');
m = get(gca,'XTickLabel'); % Set font size of axis
set(gca,'XTickLabel',m,'fontsize',13);
end
if figurekey~=1
end

Accepted Answer

Walter Roberson
Walter Roberson on 5 Dec 2022
We do not have your functions. What we do have is your line of code
[a,b]=H2MSA_conversion(lifetime(j),efficiency(i), msaprice);
which expects H2MSA_conversion to return two outputs, here called a and b.
And we have your statement that you have
function [H2MSA_eff]=H2MSA_conversion(senslife,eta,msaprice)
Notice that returns only a single output, here named H2MSA_eff . That would go into a in the caller, but there is no output that can go into b in the caller.

More Answers (0)

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!