Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
Waleed new
Waleed new el 2 de Sept. de 2018
Respondida: Amir Xz el 2 de Sept. de 2018
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 .

Respuestas (1)

Amir Xz
Amir Xz el 2 de Sept. de 2018
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])

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by