Why am I getting the error "Too many output arguments"?

2 ビュー (過去 30 日間)
Aftab Mohammed
Aftab Mohammed 2024 年 3 月 3 日
回答済み: Walter Roberson 2024 年 3 月 3 日
%initialise paramteres
A = 1.7;
k = 1.380658*(10^-23);
q = 1.6 * (10^-19);
Eg = 1.1;
Ior = 19.9693*(10^-6);
Iscr = 3.3;
ki = 1.7 * (10^-3);
ns = 40;
np = 2;
Rs = 5*(10^-5);
Rp = 5*(10^5);
Tr = 301.18;
Ta = 25;
%array error = 1;
amb = [25 40 60];
irr = [0.3 0.5 1];
%Evaluate
hold on
for i=1:3
Ipv = [];
Vpv = [];
Ppv = [];
G= irr(i);
Tc = Ta + (0.2*G) + 273.18;
Isc = (Iscr + ki*(Tc-Tr))*G;
Is = Ior * ((Tc/Tr)^3) * exp(q*Eg*(1/Tr-1/Tc)/(k*A));
I = Isc;
V = 0;
while I>0
while error>0.0001
f1= I-(np*Isc)+(np*Is)*(exp(q*((V/ns)+(I*Rs/np))/(A*k*Tc))-1)+(((V*np/ns)+(I*Rs))/(Rp));
df1= 1+(Rs/Rp)+((q*Is*Rs)/(A*k*Tc))*(exp(q*((V/ns)+(I*Rs/np))/(A*k*Tc)));
I= I-(f1/df1);
error=abs(f1/df1);
end
Ipv= [Ipv I];
Vpv = [Vpv V];
Ppv= [Ppv I*V];
V = V+0.1;
error = 1;
end
plot(Vpv, Ipv);
% plot(Vpv, Ppv);
end
Error using error
Too many output arguments.

採用された回答

the cyclist
the cyclist 2024 年 3 月 3 日
You are confusing MATLAB by using error (a MATLAB function) as a variable name.
I changed that variable name to errorVal, and initialized it to -Inf.
%initialise paramteres
A = 1.7;
k = 1.380658*(10^-23);
q = 1.6 * (10^-19);
Eg = 1.1;
Ior = 19.9693*(10^-6);
Iscr = 3.3;
ki = 1.7 * (10^-3);
ns = 40;
np = 2;
Rs = 5*(10^-5);
Rp = 5*(10^5);
Tr = 301.18;
Ta = 25;
%array error = 1;
amb = [25 40 60];
irr = [0.3 0.5 1];
%Evaluate
errorVal = -Inf;
hold on
for i=1:3
Ipv = [];
Vpv = [];
Ppv = [];
G= irr(i);
Tc = Ta + (0.2*G) + 273.18;
Isc = (Iscr + ki*(Tc-Tr))*G;
Is = Ior * ((Tc/Tr)^3) * exp(q*Eg*(1/Tr-1/Tc)/(k*A));
I = Isc;
V = 0;
while I>0
while errorVal>0.0001
f1= I-(np*Isc)+(np*Is)*(exp(q*((V/ns)+(I*Rs/np))/(A*k*Tc))-1)+(((V*np/ns)+(I*Rs))/(Rp));
df1= 1+(Rs/Rp)+((q*Is*Rs)/(A*k*Tc))*(exp(q*((V/ns)+(I*Rs/np))/(A*k*Tc)));
I= I-(f1/df1);
errorVal=abs(f1/df1);
end
Ipv= [Ipv I];
Vpv = [Vpv V];
Ppv= [Ppv I*V];
V = V+0.1;
errorVal = 1;
end
plot(Vpv, Ipv);
% plot(Vpv, Ppv);
end

その他の回答 (2 件)

Torsten
Torsten 2024 年 3 月 3 日
編集済み: Torsten 2024 年 3 月 3 日
You don't initialize "error" in your code by giving it a value before you use it in the while loop.
That's why MATLAB assumes error to be the built-in "error" command:

Walter Roberson
Walter Roberson 2024 年 3 月 3 日
You do not initialize error before you use it.
error happens to be the name of an important Mathworks function -- a function that is not permitted to return a value and so cannot exist in a form
while error>0.0001
Best would be if you used a different variable name (and made sure to initialize it). Compromise would be if you assigned to error before you use it.

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by