Driven Damped Pendulum Axes Question
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Beantwortet: MKG am 17 Feb. 2015
Hello, I am quite new to MATLab, this is my very first program, which is also a uni assignment. This is my program thus far:
theta_dotdot=-(g/l)*sin(theta) - (c/m*l^2)*theta_dot; %motion eqn
axis([0 0 -2*pi -2*pi]);
What I have done so far (the code above explained): 1.Giving some values (the first part of the code). 2.The equation of motion (%motion eqn). 3.Theta and Theta_dot increasing in value (recommended method/code I was given in the assignment). 4. Figure - doesn't work, and I am not quite sure how it should work. 5. Plot - no reason for it not to work, I assume it doesn't plot anything because of the figure error above. 6. t increasing. 7. Everything above is looped, with t=t+dt What I need to do: Firstly, I need it to give me a figure of the pendulum positions (don't know how to explain this better)- the figure part of the code Secondly, I need it to plot theta_dotdot, theta. I think I got this part right, but the program does not run that part yet, im assuming because of the errors in the figure part.
There are the erros im getting:
>> run Untitled2
Error using set
Bad property value found.
Object Name: axes
Property Name: 'XLim'
Values must be increasing and non-NaN.
Error in axis>LocSetLimits (line 201)
Error in axis (line 93)
Error in Untitled2 (line 17)
axis([0 0 -2*pi -2*pi]);
Error in run (line 63)
evalin('caller', [script ';']);
If an answer can not be provided, I could really use some help on the errors, why am I getting them, what do they mean.
Youssef Khmou am 16 Feb. 2015
Bearbeitet: Youssef Khmou am 16 Feb. 2015
The implementation is acceptable, the first remark is that visualization commands of results should be outside the loop, otherwise you obtain N plots where N is the number of iterations. While loop in this case can be changed into for loop but not necessary, the following version is working , but the physical interpretation still needs correction of the code, try to adjust it :
d2theta(cc)=-(g/l)*sin(thet) - (c/m*l^2)*dtheta; %motion eqn
% axis([0 0 -2*pi -2*pi]);
% hold on;
Weitere Antworten (1)
MKG am 17 Feb. 2015
Hello, try the following code for your x limits: axis([-2*pi 0 -2*pi 0])
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!