How to solve a system of equations when multiple parameters changes

4 visualizaciones (últimos 30 días)
My question regards solving system when multiple terms vary for example:
AngleL=[180;202.500000000000;225;247.500000000000;270;292.500000000000;315;337.500000000000;0;22.5000000000000;45;67.5000000000000;90;112.500000000000;135;157.500000000000];
AngleR=[0;22.5000000000000;45;67.5000000000000;90;112.500000000000;135;157.500000000000;180;202.500000000000;225;247.500000000000;270;292.500000000000;315;337.500000000000];
PedalLH=[-30;-35;-42;-47;-35;-12;25;80;115;95;55;30;11;-5;-12;-27];
PedalLV=[-48;-60;-110;-155;-250;-250;-295;-325;-310;-275;-195;-120;-50;-20;-30;-40];
PedalRH=[115;95;55;30;11;-5;-12;-27;-30;-35;-42;-47;-35;-12;25;80];
PedalRV=[-310;-275;-195;-120;-50;-20;-30;-40;-48;-60;-110;-155;-250;-250;-295;-325];
SizeVec=length(AngleL);
AllFBRy=cell(SizeVec,1);
AllFBLy=cell(SizeVec,1);
AllFBRx=cell(SizeVec,1);
AllFBLx=cell(SizeVec,1);
AllTs=cell(SizeVec,1);
syms FBRy FBLy FBRx FBLx Tshaft
SizeVec=length(AngleL);
for idx = 1:SizeVec
[solFBRy,solFBLy,solFBRx,solFBLx,solTshaft]=vpasolve(FBRy(idx)+FBLy(idx)+PedalRV(idx)+PedalLV(idx)==0,...
FBRx(idx)+FBLx(idx)+PedalRH(idx)+PedalLH(idx)==0,...
-1.51*FBRy(idx)+1.51*FBLy(idx)-4.4*PedalRV(idx)+4.4*PedalLV(idx)==0,...
1.51*FBRx(idx)-1.51*FBLx(idx)+4.4*PedalRH(idx)-4.4*PedalLH(idx)==0,...
-Tshaft(idx)+7*cosd(AngleR(idx))*PedalRV(idx)-7*sind(AngleR(idx))*PedalRH(idx)+7*cosd(AngleL(idx))*PedalLV(idx)-7*sind(AngleL(idx))*PedalLH(idx)==0);
AllFBRy{idx}=solFBRy;
AllFBLy{idx}=solFBLy;
AllFBRx{idx}=solFBRx;
AllFBLx{idx}=solFBLx;
AllTs{idx}=solTshaft;
end
I do not understand why I am getting an indexing error and my code only finds the solution for the first iteration of the cycle.

Respuestas (1)

Zuber Khan
Zuber Khan el 11 de Oct. de 2024
Hi,
It seems like the issue might be due to trying to index symbolic variables in the vpasolve function. The variables 'FBRy', 'FBLy', 'FBRx', 'FBLx', and 'Tshaft' are individual scalar symbols and shouldn't be treated like arrays. Try using them directly in vpasolve without any indexing, and that should help.
The correct implementation of vpasolve function would be as follows:
[solFBRy, solFBLy, solFBRx, solFBLx, solTshaft] = vpasolve(...
FBRy + FBLy + PedalRV(idx) + PedalLV(idx) == 0, ...
FBRx + FBLx + PedalRH(idx) + PedalLH(idx) == 0, ...
-1.51*FBRy + 1.51*FBLy - 4.4*PedalRV(idx) + 4.4*PedalLV(idx) == 0, ...
1.51*FBRx - 1.51*FBLx + 4.4*PedalRH(idx) - 4.4*PedalLH(idx) == 0, ...
-Tshaft + 7*cosd(AngleR(idx))*PedalRV(idx) - 7*sind(AngleR(idx))*PedalRH(idx) ...
+ 7*cosd(AngleL(idx))*PedalLV(idx) - 7*sind(AngleL(idx))*PedalLH(idx) == 0, ...
[FBRy, FBLy, FBRx, FBLx, Tshaft]);
I hope it resolves the issue.
Regards,
Zuber

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by