Why am I getting the error "Too many output arguments"?
2 views (last 30 days)
Show older comments
Aftab Mohammed
on 3 Mar 2024
Answered: Walter Roberson
on 3 Mar 2024
%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
0 Comments
Accepted Answer
the cyclist
on 3 Mar 2024
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
0 Comments
More Answers (2)
Walter Roberson
on 3 Mar 2024
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.
0 Comments
See Also
Categories
Find more on Search Path 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!