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 view (last 30 days)
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])

Accepted Answer

Star Strider
Star Strider on 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

More Answers (0)

Categories

Find more on Mathematics 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!