필터 지우기
필터 지우기

How to plot forcing function in matlab

조회 수: 1 (최근 30일)
Bilal sadiq
Bilal sadiq 2018년 7월 18일
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개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by