How can I reformat my loop to get result for given equations?
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
The task is as follows:
Write Matlab program to simulate 2 seconds of engine motion starting at initial conditions of omega2=2*pi rad/s and TH2 = 0 degrees. Assume linear angular accel of alpha2 = 0.5*time (that's total elapsed time, NOT time increment dt).
Set time increment dt such that it always corresponds to a 2 degree increment in TH2 based on current omega2.
My attempt at coding:
w2=2*pi;
TH2=0;
t=2
a2=0.5*t;
L2=50;
L3=150;
for n=1:2:360
TH3(n)=acosd((L2*cosd(TH2))/L3)
d1(n)=((L2*sind(TH2))-(L3*sind(TH3)))
w3(n)=(L2*w2*sind(TH2))/L3*sind(TH3)
d2(n)=(L2*w2*cosd(TH2))-L3*w3*cosd(TH3)
a3(n)=((-L3*w3^2*cosd(TH3))+(L2*a2*sind(TH2)))+(L2*w2^2*cosd(TH2))/L3*sind(TH3)
d3(n)=(L2*a2*cosd(TH2))-(L2*w2^2*sind(TH2))-(L3*a3*cosd(TH3))+(L3*w3^2*sind(TH3))
end
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in DynamicsPistonProject (line 12)
d1(n)=((L2*sind(TH2))-(L3*sind(TH3)))
I understand that the error will not allow me to continue my loop as written. Is there a better way to write my program to get the output desired?
2 Kommentare
Torsten
am 24 Jun. 2016
Maybe you mean TH3(n) instead of TH3 in all your equations ?
Best wishes
Torsten.
Emily Gobreski
am 24 Jun. 2016
Antworten (1)
Kiran Prasad
am 24 Jun. 2016
0 Stimmen
I think Torsten is right. If you run it afterwards you shouldn't get a dimension mismatch. Let us know if this still doesn't work. Best, Kiran
2 Kommentare
Emily Gobreski
am 24 Jun. 2016
Bearbeitet: Stephen23
am 24 Jun. 2016
Kiran Prasad
am 24 Jun. 2016
I haven't gone through your logic as of yet, but I would get rid of TH2(n) and keep it as TH2. Right now TH2 isn't a vector.
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!