how to create fourier transform and laplace from basic signals?

35 views (last 30 days)
fprintf('Please choose any type of signal below.\n1. Impulse\n2. Step function\n3. DC Source\n4. Signum function\n5. Rising exponent function\n6. Cosine function\n7. Sine function\n8. Square function\n9. Triangular function\n10. Symmetrical decaying exponent function')
s=input('\nSignal number: ');
a=input('Please choose any of these signal transformation\n1. Time scale\n2. Time shift\n3. Time inversion\n4. Amplitude scale\n5. Amplitude Shift\n6. Amplitude inversion\n');
switch (s)
case 7
A=input('Enter Amplitude:');
F= input('Enter frequency:');
t=0:0.01:1;
y = A*sin(2*pi*F*t);
figtitle = 'Sine Wave';
switch (a)
case 1 %time scale
z= input('Enter time scale value:');
tmod=z\t;
ymod=y;
case 2 %time shifting
z= input('Enter time shifting value:');
tmod=t-z;
ymod=y;
case 3 %time inversion
tmod=-t;
ymod=y;
case 4 %amplitude scale
z=input('Enter amplitude scale value:');
tmod=t;
ymod=z*y;
case 5 %amplitude shift
z=input('Enter amplitude shift value:');
tmod=t;
ymod=y-z;
case 6 %amplitude inversion
tmod=t;
ymod=-y;
end
plot(t,y,'b')
hold on
plot(tmod,ymod,'k')
hold off
title(figtitle)
xlabel('Time')
ylabel('Amplitude')
grid on
% adjust limits to create padding
xlim(xlim + [-1 1]*0.2)
ylim(ylim + [-1 1]*1.5)
%Fourier Transform
%Laplace Transform
case 8
A=input('Enter Amplitude:');
f= input('Enter frequency:');
t =0:0.01:1;
sqwv = A*sign(sin(2*pi*t*f));
figtitle = 'Square Wave';
switch (a)
case 1 %time scale
z=input('Enter time scale value:');
tmod= z\t;
ymod=sqwv;
case 2 %time shifting
z=input('Enter time shifting value:');
tmod= t-z;
ymod=sqwv;
case 3 %time inversion
tmod= -t;
ymod=sqwv;
case 4 %amplitude scale
z=input('Enter scale value:');
tmod= t;
ymod=z*sqwv;
case 5 %amplitude shift
z=input('Enter amplitude shift value:');
tmod= t;
ymod=sqwv+z;
case 6 %amplitude inversion
tmod= t;
ymod=-sqwv;
end
plot(t,sqwv,'b')
hold on
plot(tmod,ymod,'k')
hold off
title(figtitle)
xlabel('Time')
ylabel('Amplitude')
grid on
% adjust limits to create padding
xlim(xlim + [-1 1]*0.3)
ylim(ylim + [-1 1]*1.5)
%Fourier Transform
%Laplace Transform
end

Accepted Answer

Alagu Sankar Esakkiappan
Alagu Sankar Esakkiappan on 25 Jan 2022
Hi Mya,
You may make use of fft and laplace to compute Fourier and Laplace transforms for a Signal in MATLAB. You may refer to the following code snippet ( in reference to your above code ) as example:
Fs = 1000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 0.25; % seconds
t = (0:dt:StopTime-dt)';
A = 230; % Amplitude for Signal
F = 50; % Frequency for Signal
y = A*sin(2*pi*F*t);
% Original Sine Wave
subplot(2,1,1);
plot(t,y);
yFourier = fft(y);
f = (0:length(yFourier)-1)*F/length(yFourier);
% Frequency Response for Sine Wave
subplot(2,1,2);
plot(f,abs(yFourier));
syms t
y = A*sin(2*pi*F*t);
g = laplace(y) % Laplace Transform Equation for Sine Wave
g = 

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by