Skip to content

Instantly share code, notes, and snippets.

@diogojorgebasso
Created April 12, 2024 04:19
Show Gist options
  • Save diogojorgebasso/84d3d49724165ccce543a7059dcfb2a1 to your computer and use it in GitHub Desktop.
Save diogojorgebasso/84d3d49724165ccce543a7059dcfb2a1 to your computer and use it in GitHub Desktop.
Transformations of signal in Octave
function transformationSignal(a,b,A,B)
close all;
clc;
t = -6:0.01:6;
for i=1:size(t,2)
if(t(i)<-1) x(i)=0;
elseif(t(i)<0) x(i)=-1;
elseif(t(i)<=2) x(i) = t(i)/2;
else x(i) = 0;
endif
endfor
figure;
plot(t,x);
grid;
title('Sinal original');
xlabel('tempo[s]');
ylabel('Amplitude');
xlim([-6 6]);
figure;
plot((t-b)/a,A*x+B);
grid;
title('Sinal transformado');
xlabel('tempo[s]');
ylabel('Amplitude');
xlim([-6 6]);
figure;
plot(t, (x+flip(x))/2);
grid;
title('Sinal par');
xlabel('tempo[s]');
ylabel('Amplitude');
xlim([-6 6]);
figure;
plot(t, (x-flip(x))/2);
grid;
title('Sinal impar');
xlabel('tempo[s]');
ylabel('Amplitude');
xlim([-6 6]);
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment