From: Azrul on
hi ..
im new with matlab and having difficulties on plotting the graph.. supposed if i have :
------------------------------------------------------------------------------------------------------------------
Time = [0 10];

[time_hist1, state_hist1] = ode45(@dydt2DOF,Time,Y0);

% Plotting the vehicle body displacement
subplot(2,2,1);
plot(time_hist1, state_hist1(:,1),'-.');
ylabel('x1 [m]'); xlabel('Time[s]');


% Plotting the body acceleration
subplot(2,2,2);
acceleration005 = (c005*(state_hist1(:,4)-state_hist1(:,2))+k*
(state_hist1(:,3)-state_hist1(:,1)))/m;

plot(time_hist1, acceleration005,'--');
ylabel('a1 [m/s^2]'); xlabel('Time[s]');

% Plotting the suspension travel
subplot(2,2,3);
plot(time_hist1, (state_hist1(:,1)-state_hist1(:,3)),'--');hold on;
ylabel('x1-x2 [m]'); xlabel('Time[s]');

%Plotting the dynamic tyre force
subplot(2,2,4);
plot(time_hist1, kt*(state_hist1(:,3)-road),'--');hold on;
ylabel('Dynamic tyre force [N]'); xlabel('Time[s]');
-------------------------------------------------------------------------------------------------------------------
my question is how do i specify that for the 2nd,3rd and 4th graph, i only want matlab to show me the graph for T=[0 1] instead of the whole T=[0 10] . I have tried to put T=[0 1] before the 'subplot(2,2,2);' line but clearly its not the way to do it.

also, does anyone know how to type damping ratio (sigma) symbol in matlab ?

thank you :)
From: Yi Cao on
You use 'set(gca,'XLim',[0 1]);' for each subplot.
To show the greek letter, 'sigma', you can use the latex command, '\sigma' within any text string. For example, title('This is \sigma').

HTH
Yi

"Azrul " <azrul.afifi(a)gmail.com> wrote in message <hpv2mk$rio$1(a)fred.mathworks.com>...
> hi ..
> im new with matlab and having difficulties on plotting the graph.. supposed if i have :
> ------------------------------------------------------------------------------------------------------------------
> Time = [0 10];
>
> [time_hist1, state_hist1] = ode45(@dydt2DOF,Time,Y0);
>
> % Plotting the vehicle body displacement
> subplot(2,2,1);
> plot(time_hist1, state_hist1(:,1),'-.');
> ylabel('x1 [m]'); xlabel('Time[s]');
>
>
> % Plotting the body acceleration
> subplot(2,2,2);
> acceleration005 = (c005*(state_hist1(:,4)-state_hist1(:,2))+k*
> (state_hist1(:,3)-state_hist1(:,1)))/m;
>
> plot(time_hist1, acceleration005,'--');
> ylabel('a1 [m/s^2]'); xlabel('Time[s]');
>
> % Plotting the suspension travel
> subplot(2,2,3);
> plot(time_hist1, (state_hist1(:,1)-state_hist1(:,3)),'--');hold on;
> ylabel('x1-x2 [m]'); xlabel('Time[s]');
>
> %Plotting the dynamic tyre force
> subplot(2,2,4);
> plot(time_hist1, kt*(state_hist1(:,3)-road),'--');hold on;
> ylabel('Dynamic tyre force [N]'); xlabel('Time[s]');
> -------------------------------------------------------------------------------------------------------------------
> my question is how do i specify that for the 2nd,3rd and 4th graph, i only want matlab to show me the graph for T=[0 1] instead of the whole T=[0 10] . I have tried to put T=[0 1] before the 'subplot(2,2,2);' line but clearly its not the way to do it.
>
> also, does anyone know how to type damping ratio (sigma) symbol in matlab ?
>
> thank you :)
From: Azrul on
it works ..thanks a lot .. :)