BASIC SIGNAL GENERATOR

Version 1.0.0 (9,08 ko) par BARATAM
IT IS A SIGNAL GENERATOR GIVING 6 OUTPUTS: Ramp , Rectangular ,Sine,Step, Triangular ,Exponent and Impulse
4 téléchargements
Mise à jour 16 nov. 2024

Afficher la licence

% Clear workspace and close figures
clear;
close all;
clc;
% User input for function selection
disp('Select the function to plot:');
disp('1: Ramp Function');
disp('2: Rectangular Pulse Function');
disp('3: Sine Wave Function');
disp('4: Square Wave Function');
disp('5: Triangular Pulse Function');
disp('6: Exponential Function')
disp('7: Impulse Function')
choice = input('Enter your choice (1-7): ');
% Ramp Functions
if choice == 1
t1 = -10:0.1:10;
n1 = length(t1);
rampf = zeros(n1, 1);
for i = 1:n1
rampf(i) = t1(i);
end
plot(t1, rampf);
title('RAMP FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Ramp');
grid on;
% Rectangular Function
elseif choice == 2
t2 = -10:0.1:10;
n2 = length(t2);
rectanglef = zeros(n2, 1);
for i = 1:n2
if (abs(t2(i)) <= 1)
rectanglef(i) = 1;
else
rectanglef(i) = 0;
end
end
plot(t2, rectanglef);
title('RECTANGULAR PULSE FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Rectangle');
grid on;
% Sine Function
elseif choice == 3
t4 = -10:0.1:10;
n4 = length(t4);
sinef = zeros(n4, 1);
for i = 1:n4
sinef(i) = sin(2 * pi * t4(i) * 0.5);
end
plot(t4, sinef);
title('SINE WAVE FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Sine');
grid on;
% Square Function
elseif choice == 4
squareWave = @(t) square(2 * pi * t);
t = -10:0.1:10;
y = squareWave(t);
figure;
plot(t, y);
title('SQUARE WAVE FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('square');
grid on;
% Triangular Function
elseif choice == 5
t6 = -10:0.1:10;
n6 = length(t6);
triangle = zeros(n6, 1);
for i = 1:n6
if (abs(t6(i)) <= 2)
triangle(i) = 1 - abs(t6(i) / 2);
end
end
plot(t6, triangle);
title('TRIANGLE PULSE FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('triangle');
grid on;
%exponential function
elseif choice == 6
t6 = -10:0.1:10;
n6 = length(t6);
exponent = zeros(n6, 1);
for i = 1:n6
exponent(i) = exp(t6(i));
end
plot(t6, exponent);
title('EXPONENTIAL FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Exponent');
grid on;
%impluse function
elseif choice == 7
t7 = -10:0.1:10;
n7 = length(t7);
impulse = zeros(n7);
for i = 1:n7
if(t7(i)==0)
impulse(i)=1;
end
end
plot(t7,impulse);
title('IMPULSE FUNCTION');
xlabel('Time (s)');
ylabel('Amplitude');
legend('impulse');
grid on;
else
disp('Invalid choice. Please select a number between 1 and 6.');
end

Citation pour cette source

BARATAM (2025). BASIC SIGNAL GENERATOR (https://fr.mathworks.com/matlabcentral/fileexchange/175853-basic-signal-generator), MATLAB Central File Exchange. Extrait(e) le .

Compatibilité avec les versions de MATLAB
Créé avec R2024b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux
Tags Ajouter des tags

Community Treasure Hunt

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

Start Hunting!
Version Publié le Notes de version
1.0.0