Good morning, I'm trying to solve 8 equations with 8 unknowns using fsolve and want to see how results are changing with one parameter (Vn1). When used it doesn't work correctly - it overwrites score and at the end there is only result with last value of Vn1. Can you help me?
Here is my code:
clear
clc
Vn=100;
Vn1=[10;11;12;13];
Vn3=20;
wn=1;
lambda1=0.1;
lambda3=0.2;
R1=0.99;
R3=0.98;
fun1 = @(x) [(Vn-Vn1+x(1)-x(2));
x(2)-Vn3+x(3)-x(4);
x(5)-wn.*(1+lambda1.*R1./(1-lambda1));
x(6)-x(7).*(1+lambda3.*R3./(1-lambda3));
x(7).*x(2)-wn.*(Vn-Vn1)-x(5.)*x(1);
x(8).*x(4)-x(7).*(x(2)-Vn3)-x(6).*x(3);
x(1)-Vn1+lambda1.*Vn1;
x(3)-Vn3+lambda3.*Vn3];
x0(8,4)=0;
x = fsolve(fun1,x0);
plot(Vn1,x(8))
Thank you in advance!