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 visualización (últimos 30 días)
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])

Respuesta aceptada

Star Strider
Star Strider el 18 de Oct. de 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

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by