Fcs Post Lab 2

download Fcs Post Lab 2

of 10

Transcript of Fcs Post Lab 2

  • 8/13/2019 Fcs Post Lab 2

    1/10

    Question # 1: Plot the position and the speed in separate graphs.

    Source code:

    %functionfunction dXdt=mass_spring(t,X)M=705; % (Kg)B=30; % (Nsec/m)Fa=300; % (N)K=15; % (N/m)r=1; % dX/dtdXdt(1,1)=X(2); % SpeeddXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M; %Displacement

    % Program codeclear allclose allclcX0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring',[0 200],X0);figure; plot(t,X(:,1));xlabel('Time(t)');ylabel('Speed');title('Mass spring system');legend('Speed');grid;figure;plot(t,X(:,2),'r');xlabel('Time(t)');ylabel('Position');title('Mass spring system');legend('Position');grid on;

  • 8/13/2019 Fcs Post Lab 2

    2/10

  • 8/13/2019 Fcs Post Lab 2

    3/10

    Question # 3:

    Superpose the results and compare with the linear case r=1 and plot all three cases in the same

    plot window.

    Source code:

    Function 1:

    function dXdt=mass_spring(t,X)M=705; % (Kg)B=30; % (Nsec/m)Fa=300; % (N)K=15; % (N/m)r=1; % dX/dtdXdt(1,1)=X(2); % SpeeddXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M; % Displacement

    Function 2:function dXdt=mass_spring2(t,X)M=705; % (Kg)B=30; % (Nsec/m)Fa=300; % (N)K=15; % (N/m)r=2; % dX/dtdXdt(1,1)=X(2); % SpeeddXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M; % Displacement

    Function 3:

    function dXdt=mass_spring3(t,X)M=705; % (Kg)B=30; % (Nsec/m)Fa=300; % (N)K=15; % (N/m)r=3; % dX/dtdXdt(1,1)=X(2); % SpeeddXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M; % Displacement

    %program codingclear allclose allclcX0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring',[0 200],X0);plot(t,X(:,1));xlabel('Time(t)');ylabel('Speed');title('Mass spring system');hold;X0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring2',[0 200],X0);plot(t,X(:,1),'g');hold on;X0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring3',[0 200],X0);plot(t,X(:,1),'r');legend('r = 1','r = 2','r = 3');

  • 8/13/2019 Fcs Post Lab 2

    4/10

    grid on;figure;X0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring',[0 200],X0);plot(t,X(:,2),'-');xlabel('Time(t)');

    ylabel('Position');title('Mass spring system');hold on;X0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring2',[0 200],X0);plot(t,X(:,2),'g');hold on;X0=[0;0];% (Initial speed and position)[t,X]=ode45('mass_spring3',[0 200],X0);plot(t,X(:,2),'r');grid on;legend('r = 1','r = 2','r = 3');title('Mass spring system');

  • 8/13/2019 Fcs Post Lab 2

    5/10

    Question # 4:Change the values of each parameters, such as

    Compare the results and describe the effects.

    Answer: Source code and functions are same as question just values are changed.

    Changing the value of mass M,

  • 8/13/2019 Fcs Post Lab 2

    6/10

  • 8/13/2019 Fcs Post Lab 2

    7/10

    When co-efficient of friction B is changed,

  • 8/13/2019 Fcs Post Lab 2

    8/10

    When the value of elastic characteristic Kis changed,

  • 8/13/2019 Fcs Post Lab 2

    9/10

    When Force Fa is changed,

  • 8/13/2019 Fcs Post Lab 2

    10/10