Sine Wave Generator
Version 1.0.0 (1,35 ko) par
Umar
This script generates a sine wave based on user-defined frequency and amplitude.
%clear work space and command window
clear;clc;
%user input for frequency and amplitude
frequency=input('Enter the frequency of the sine wave (Hz): ');
amplitude=input('Enter the amplitude of the sine wave: ');
%time vector from 0 to 1 second with a sampling rate of 1000Hz
t=0:0.001:1;
%Generate the sine wave
y=amplitude*sin(2*pi*frequency*t);
%plotting the sine wave
figure;
plot(t,y,'LineWidth',2);
title('Sine Wave');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
%save the plot as PNG file
saveas(gcf,'sine_wave_plot.png');
disp('Sine wave plot saved as sine_wave_plot.png');
Citation pour cette source
Umar (2026). Sine Wave Generator (https://fr.mathworks.com/matlabcentral/fileexchange/181628-sine-wave-generator), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Créé avec
R2025a
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS LinuxTags
Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
| Version | Publié le | Notes de version | |
|---|---|---|---|
| 1.0.0 |
