Check for missing argument or incorrect argument data type in call to function 'solve'. Error in LinearProject (line 35) I=solve(eq1, eq2, eq3, eq4); The program just print the first 4 i's. The program should print 44 i's. How can I solve?

3 views (last 30 days)
syms i1 i2 i3 i4 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11;
eqn1 = 3-r1*(i1)-r2*(i1-i4)-r3*(i1+i2)-r4*i1==0;
eqn2 = 3-r7*(i2 + i3)-r8*(i2+i4)-r3*(i2+i1)-r5*(i2)-r6*(i2+i3)== 0;
eqn3 = 3-r7*(i2+i3)-r10*(i3-i4)-r6*(i3+i2)-r9*i3==0;
eqn4 = r2*(i4-i1)+r8*(i2+i4)+r10*(i4-i3)+r11*i4==0;
Eqn=[eqn1; eqn2; eqn3; eqn4];
fprintf('These is the 4 equations: \n');
disp(Eqn);
v1=[171;104;104;104;104;104;104;104;104;104;104];
v2=[12;79;12;12;12;12;12;12;12;12;12];
v3=[12;12;79;12;12;12;12;12;12;12;12];
v4=[12;12;12;79;12;12;12;12;12;12;12];
v5=[12;12;12;12;79;12;12;12;12;12;12];
v6=[12;12;12;12;12;79;12;12;12;12;12];
v7=[12;12;12;12;12;12;79;12;12;12;12];
v8=[12;12;12;12;12;12;12;79;12;12;12];
v9=[12;12;12;12;12;12;12;12;79;12;12];
v10=[12;12;12;12;12;12;12;12;12;79;12];
v11=[12;12;12;12;12;12;12;12;12;12;79];
V=[v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11];
fprintf('The matrix of voltage: \n');
disp(V)
j=0;
while j<2
j=j+1;
eq1 = 3-V(j,1)*(i1)-V(j,2)*(i1-i4)-V(j,3)*(i1+i2)-V(j,4)*i1==0;
eq2 = 3-V(j,4)*(i2 + i3)-V(j,8)*(i2+i4)-V(j,3)*(i2+i1)-V(j,5)*(i2)-V(j,6)*(i2+i3)== 0;
eq3 = 3-V(j,7)*(i2+i3)-V(j,10)*(i3-i4)-V(j,6)*(i3+i2)-V(j,9)*i3==0;
eq4 = V(j,2)*(i4-i1)+V(j,8)*(i2+i4)+V(j,10)*(i4-i3)+V(j,11)*i4==0;
I=solve(eq1, eq2, eq3, eq4);
i1 = double(I.i1);
i2 = double(I.i2);
i3 = double(I.i3);
i4 = double(I.i4);
P= V(j,1)*i1^2+V(j,2)*i1^2+V(j,3)*i1^2+V(j,4)*i1^2+V(j,4)*i2^2+V(j,8)*i2^2+V(j,3)*i2^2+V(j,5)*i2^2+V(j,6)*i2^2+V(j,7)*i3^2+V(j,10)*i3^2+V(j,6)*i3^2+V(j,9)*i3^2+V(j,2)*i4^2+V(j,8)*i4^2+V(j,10)*i4^2+V(j,11)*i4^2;
fprintf('The value for i1 is: \n');
disp(i1);
fprintf('The value for i2 is: \n');
disp(i2);
fprintf('The value for i3 is: \n');
disp(i3);
fprintf('The value for i4 is: \n');
disp(i4);
fprintf('The power is: \n');
disp(P);
fprintf('Going to the next configuration\n\n');
end

Answers (1)

Chirag Nighut
Chirag Nighut on 14 Dec 2020
I understand that you wish to get the values of i1, i2, i3 and i4 which are symbolic variables defined.
However in the first iteration of the for loop, you are assigning values to i1, i2, i3 and i4 and therefore in he second iteration of the while loop, when you use them in thew equations, they are no more as variables. Therefore you ar getting an error.
In order o solve this error, you can rename i1 to k1 and use it to calculate power and print.
Here is the code for the same:
syms i1 i2 i3 i4 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11;
eqn1 = 3-r1*(i1)-r2*(i1-i4)-r3*(i1+i2)-r4*i1==0;
eqn2 = 3-r7*(i2 + i3)-r8*(i2+i4)-r3*(i2+i1)-r5*(i2)-r6*(i2+i3)== 0;
eqn3 = 3-r7*(i2+i3)-r10*(i3-i4)-r6*(i3+i2)-r9*i3==0;
eqn4 = r2*(i4-i1)+r8*(i2+i4)+r10*(i4-i3)+r11*i4==0;
Eqn=[eqn1; eqn2; eqn3; eqn4];
fprintf('These is the 4 equations: \n');
disp(Eqn);
v1=[171;104;104;104;104;104;104;104;104;104;104];
v2=[12;79;12;12;12;12;12;12;12;12;12];
v3=[12;12;79;12;12;12;12;12;12;12;12];
v4=[12;12;12;79;12;12;12;12;12;12;12];
v5=[12;12;12;12;79;12;12;12;12;12;12];
v6=[12;12;12;12;12;79;12;12;12;12;12];
v7=[12;12;12;12;12;12;79;12;12;12;12];
v8=[12;12;12;12;12;12;12;79;12;12;12];
v9=[12;12;12;12;12;12;12;12;79;12;12];
v10=[12;12;12;12;12;12;12;12;12;79;12];
v11=[12;12;12;12;12;12;12;12;12;12;79];
V=[v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11];
fprintf('The matrix of voltage: \n');
disp(V)
j=0;
while j<2
j=j+1;
eq1 = 3-V(j,1)*(i1)-V(j,2)*(i1-i4)-V(j,3)*(i1+i2)-V(j,4)*i1==0;
eq2 = 3-V(j,4)*(i2 + i3)-V(j,8)*(i2+i4)-V(j,3)*(i2+i1)-V(j,5)*(i2)-V(j,6)*(i2+i3)== 0;
eq3 = 3-V(j,7)*(i2+i3)-V(j,10)*(i3-i4)-V(j,6)*(i3+i2)-V(j,9)*i3==0;
eq4 = V(j,2)*(i4-i1)+V(j,8)*(i2+i4)+V(j,10)*(i4-i3)+V(j,11)*i4==0;
I=solve(eq1, eq2, eq3, eq4);
k1 = double(I.i1);
k2 = double(I.i2);
k3 = double(I.i3);
k4 = double(I.i4);
P= V(j,1)*k1^2+V(j,2)*k1^2+V(j,3)*k1^2+V(j,4)*k1^2+V(j,4)*k2^2+V(j,8)*k2^2+V(j,3)*k2^2+V(j,5)*k2^2+V(j,6)*k2^2+V(j,7)*k3^2+V(j,10)*k3^2+V(j,6)*k3^2+V(j,9)*k3^2+V(j,2)*k4^2+V(j,8)*k4^2+V(j,10)*k4^2+V(j,11)*k4^2;
fprintf('The value for i1 is: \n');
disp(k1);
fprintf('The value for i2 is: \n');
disp(k2);
fprintf('The value for i3 is: \n');
disp(k3);
fprintf('The value for i4 is: \n');
disp(k4);
fprintf('The power is: \n');
disp(P);
fprintf('Going to the next configuration\n\n');
end

Community Treasure Hunt

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

Start Hunting!