%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');
引用
Umar (2026). Sine Wave Generator (https://jp.mathworks.com/matlabcentral/fileexchange/181628-sine-wave-generator), MATLAB Central File Exchange. に取得済み.
MATLAB リリースの互換性
作成:
R2025a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linuxタグ
| バージョン | 公開済み | リリース ノート | |
|---|---|---|---|
| 1.0.0 |
