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 vue (au cours des 30 derniers jours)
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])

Réponse acceptée

Star Strider
Star Strider le 18 Oct 2014
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

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by