1 view (last 30 days)

Show older comments

V=[1,2,3,4];

A=3;

i=1;

while i<=4

C=A*V(i);

syms x y

eqn1 = C*x + y == 2;

eqn2 = -x + y == 3;

sol = solve([eqn1, eqn2], [x, y]);

xSol = double(sol.x);

ySol = double(sol.y);

i=i+1;

end

Birdman
on 27 Jan 2021

Try the following code:

clear;clc;

V=[1 2 3 4];

A=3;

for i=1:numel(V)

C(i)=A*V(i);

syms x y

eqn1=C(i)*x+y==2;

eqn2=-x+y==3;

sol=solve([eqn1 eqn2],[x y]);

xSol(i)=double(sol.x);

ySol(i)=double(sol.y);

end

Also, plot the values to see if they are correct:

figure(1);plot(C,xSol);

figure(2);plot(C,ySol);

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

Start Hunting!