# How to solve a system of equations when multiple parameters changes

3 views (last 30 days)
EldaEbrithil on 17 May 2020
Commented: EldaEbrithil on 17 May 2020
Hi all
my question regards solving system when multiple terms vary within a certain range, for example:
w_1=[1,2];
w_2=[2,3];
w_3=[3,3];
w_4=[4,5];
w_5=[5,6];
w_6=[6,7];
w_7=[7,8];
w_8=[8,9];
w_9=[9,12];
syms a b c
[sola,solb,solc] = vpasolve(w_1+w_2*a+w_3+w_4*a^4-b-w_5*a^4==0,...
a-c-w_6*b-w_7*a^4==0,...
b-w_8*c^4-w_9==0);
in this case i want to solve this 3 equations system in 3 unknowns a b c, multiple times (in this case only two times because w_i is a two components vector). I would like to solve the system neatly for the first value of all w_i and then for their second value. I used a for loop but with no success. I want to extend this situation to a more complicated one with w_i that have more than 10 components.

A for loop work, maybe you had some trouble with the indexes
w_1=[1,2];
w_2=[2,3];
w_3=[3,3];
w_4=[4,5];
w_5=[5,6];
w_6=[6,7];
w_7=[7,8];
w_8=[8,9];
w_9=[9,12];
syms a b c
SizeVec = length(w_1);
Alla = cell(SizeVec,1);
Allb = cell(SizeVec,1);
Allc = cell(SizeVec,1);
for idx = 1:SizeVec
[sola,solb,solc] = vpasolve(w_1(idx)+w_2(idx)*a+w_3(idx)+w_4(idx)*a^4-b-w_5(idx)*a^4==0,...
a-c-w_6(idx)*b-w_7(idx)*a^4==0,...
b-w_8(idx)*c^4-w_9(idx)==0);
Alla{idx} = sola;
Allb{idx} = solb;
Allc{idx} = solc;
end

#### 1 Comment

EldaEbrithil on 17 May 2020
Thank you very much!!