Sine Wave Generator
Versión 1.0.0 (1,35 KB) por
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');
Citar como
Umar (2025). Sine Wave Generator (https://la.mathworks.com/matlabcentral/fileexchange/181628-sine-wave-generator), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Se creó con
R2025a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
| Versión | Publicado | Notas de la versión | |
|---|---|---|---|
| 1.0.0 |
