I am using a simple code to calculate solution of three nonlinear equations using fsolve. But i get the error saying "Error using vertcat Dimensions of matrices being concatenated are not consistent." I checked the dimensions they are equal. Help!

1 次查看(过去 30 天)
k=1.38*10^-23;
T=25+273;
q=1.6*10^-19;
Vt=k*T/q;
Jsc=12.5e-3;
Voc=0.951;
Rp=118000;
Vmp=0.833;
Jmp=11.15e-3;
f=@(z) [4.735 - ((z(2).*Vt)/Jsc)- z(1) +0*z(3);
(Jsc-(Voc/Rp))/(exp(Voc/(z(2).*Vt)-1))-z(3) + 0*z(1);
z(3).*(exp((Vmp-Jmp.*z(1))/(z(2).*Vt))-1)+ (Vmp-Jmp.*z(1))/Rp - Jsc -Jmp];
fsolve(f,[1;1;1e-6])

采纳的回答

Star Strider
Star Strider 2014-10-18
In matrix calculations, MATLAB interprets any spaces between operations as different elements. Take out the spaces and it works:
f=@(z) [4.735-((z(2).*Vt)./Jsc)-z(1)+0*z(3);
(Jsc-(Voc./Rp))/(exp(Voc./(z(2).*Vt)-1))-z(3)+0*z(1);
z(3).*(exp((Vmp-Jmp.*z(1))./(z(2).*Vt))-1)+ (Vmp-Jmp.*z(1))./Rp-Jsc-Jmp];
ze = fsolve(f,[1;1;1e-6])
produces:
ze =
2.7061e+000
986.7183e-003
422.4400e-018

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by