How to plot forcing function in matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function [xdot]=External_input(t,x)
x1=x(1);
x2=x(2);
m=2;
g=9.8;
k=0.15;
J=0.125;
x1dot=x2;
x2dot=((m*g*k*sin(x1))-ui(t))/J;
xdot=[x1dot;x2dot];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all;close all
t=linspace(0,10,1000);
x0=[0 0];
[t,x,u]=ode45(@External_input,t,x0);
% x1=x(1);
% x2=x(2);
subplot(211);plot(t,x(:,1),'linewidth',2);grid on ;title('Pos')
subplot(212);plot(t,x(:,2),'linewidth',2);grid on ;title('Vel')
figure(2)
plot(t,u)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%f
function u=ui(t)
% For impulse
eps=0.1;
if t<eps
u=1;
else
u=0;
end
end %%%%%%%%%%%%%%%%%%%%%%%%%%%%5 Question is %%%%%%%%%%%%%%%%%%%%%
i also want to plot u input ,,,but i am unable to plot it ...can some one guide me how can i plot the u input forcing function (which i have written in a separate function )
thanks
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!