too many output arguments, ploting loop function

조회 수: 1 (최근 30일)
Lasfitri Rosanty Sinaga
Lasfitri Rosanty Sinaga 2022년 12월 5일
댓글: Lasfitri Rosanty Sinaga 2022년 12월 5일
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

채택된 답변

Walter Roberson
Walter Roberson 2022년 12월 5일
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.
  댓글 수: 1
Lasfitri Rosanty Sinaga
Lasfitri Rosanty Sinaga 2022년 12월 5일
Oh I see! I changed it to [a] and now it works! Thank you somuch!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by