필터 지우기
필터 지우기

how to make a square wave as input of transfer function in MATLAB ?

조회 수: 3 (최근 30일)
Waleed new
Waleed new 2018년 9월 2일
답변: Amir Xz 2018년 9월 2일
i'm trying to convert this simple simulink block to matlab program
function ydot = fslve(y)
kd1=6.4;
kp1=16;
phi_c=10;
ydot(1)=y(2);
ydot(2)=kp1*(phi_c-y(1))-kd1*y(2);
ydot=[ydot(1);ydot(2)];
ydot=ydot(:);
end
-----------------------------------
[t,y]=ode45(@(t,y)fslve(y),[0 10],[0 0]);
figure
plot(y(:,1))
figure
plot(y(:,2))
in matlab program i want to make phi_c as a square wave any help i appreciate it .

답변 (1개)

Amir Xz
Amir Xz 2018년 9월 2일
h=2;TimeEnd=20; % inputs
t=0:0.01:TimeEnd;
x=h/2:2*h:t(end);
n=length(x);
win=h*rectpuls(t-x(1),h);
for i=2:n
win=win+h*rectpuls(t-x(i),h);
end
plot(t,win),grid on
axis([t(1) t(end) -1 2*h])

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by