Sine Wave Generator
Version 1.0.0 (1.35 KB) by
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');
Cite As
Umar (2026). Sine Wave Generator (https://www.mathworks.com/matlabcentral/fileexchange/181628-sine-wave-generator), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
