How to solve a system of equations when multiple parameters changes
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
EldaEbrithil
le 17 Mai 2020
Commenté : EldaEbrithil
le 17 Mai 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.
0 commentaires
Réponse acceptée
Thiago Henrique Gomes Lobato
le 17 Mai 2020
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!