フィルターのクリア

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

4 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by