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.
2 Downloads
Updated 29 Jul 2025

View License

%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 (2025). Sine Wave Generator (https://uk.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 Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0