|
"niko kauppinen" <traveller74@jippii.fi> wrote in message <he192s$5vg$1@fred.mathworks.com>...
> Could someone help with this problem,
> I want to plot short range of my program
> How I can define range of my plot ex. 500-600t
>
> This is my program:
>
> %pendulum.m
> %This program will use pendulum2.m
> t = [0 1500];
> x0 = [0; 1];
> options = odeset('RelTol',1e-6,'AbsTol',1e-9);
> [t,x] = ode45('pendulum2',t,x0,options);
>
> subplot(2,1,1); plot(t,x(:,1));
> title('Plot of x as a function of time');
> xlabel('Time'); ylabel('theta');
> subplot(2,1,2); plot(x(:,1),x(:,2));
> xlabel('theta'); ylabel('theta dot');
>
> Pendulum2
>
> function f = pendulum2 (t,x)
> w = 0.85;
> gamma = 0.1;
> P1 = 1;
> P2 = 0;
> f = zeros(2,1);
> f(1) = x(2);
> f(2) = -gamma*x(2)-(1+P1*cos(w*t))*sin(x(1))-P2*sin(w*t)*cos(x(1));
>
> Regards
> Niko Kauppinen
If you mean the time range from 500 to 600
ind = t>=500 & t<=600;
plot(t(ind),x(ind,1))
etc...
|