Sine plot at a period T over a 20 second interval
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Write a MATLAB script (m) file that builds an array e(k) which consists of the waveform sin(πt) sampled at a period T over a 20 second interval. Initially choose a sample period that is small compared to the period of the waveform.
My code is as follows.
clear all
clc
T=20;
freq = 1/20;
t=0:0.01:20;
y=sin(t*pi);
figure(1)
plot(t,y)
xticks(0:2:20);
grid on
grid minor
0 commentaires
Réponses (1)
Walter Roberson
le 10 Mar 2021
T=20;
ok. But you never use T.
freq = 1/20;
Is the 20 a coincidence? But it doesn't matter, as you never use freq. Note by the way that a "freq"uency of 1/20 would mean that one period requires 20 seconds.
t=0:0.01:20;
That is a frequency of 1/0.01 which is 100 Hz.
y=sin(t*pi);
Only if your t is in radians per second instead of samples per second.
If you want 1 Hz thenyou need to complete 1 period in 1 second. 1 period is 2*pi radians. Therefore over 1 second you need to complete 2*pi radians. Your current code completes 1 radian per second instead of 2*pi radians in 1 seconds.
13 commentaires
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!