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 Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by