
Señal triangular periodica
Publicado por Adrian (20 intervenciones) el 19/11/2016 18:22:04
Hola, que código podría utilizar para generar esta señal triangular de forma automática ?

Valora esta pregunta


0
dx=0.5;
t=0:dx:2;
n=5;
sing=abs(-30.*t+30)-30;
c=round(length(sing)/2);
m=30;
sing=[sing(1:c) sing(c)+m sing(c+1:end)+m sing(end)];
tseg=[t(1:c) t(c) t(c+1:end) t(end)];
sing2=sing; tseg2=tseg;
for i=2:n
sing2=[sing2 sing];
tseg2=[tseg2 tseg+(2)*(i-1)];
end
plot(tseg2,sing2)
axis([0,10,-50,50])
clear all
close all
x=[0 1 ];
y=[0 -5 ];
for i=1:7
x=[x [i i+1]];
y=[y (-1)^i*([0 -5])];
end
plot(x,y)
xlabel('time(sec)')
grid on
t=0:dx:2;
n=5;
sing=abs(-30.*t+30)-30;
clear all
close all
amplitud=60;
periodo=40;
x=[0 periodo/2 ];
y=[0 -amplitud/2 ];
for i=1:9
x=[x [i (i+1)]*periodo/2];
y=[y (-1)^i*([0 -amplitud/2])];
end
x=[x (i+1)*periodo/2]
y=[y 0]
plot(x,y,'r')
xlabel('time(sec)')
grid on