How to solve a system of equations when multiple parameters changes

2 次查看(过去 30 天)
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.

采纳的回答

Thiago Henrique Gomes Lobato
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by