How do I plot this sine wave?
Afficher commentaires plus anciens
I am new to matlab and I am struggling with the basics. I was asked this question in class and I'm just not sure what to do "Plot one second of a sine wave with frequency 97 Hz and phase shift 97 (in degrees). The x-axis should be time not samples". Please help.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 22 Oct 2013
Modifié(e) : Image Analyst
le 22 Oct 2013
Hopefully this was just a question asked verbally in class and not an actual homework assignment. Wouldn't it just be something like this:
% Make 1000 samples in the range 0 to 1 second.
t = linspace(0, 1, 1000);
% Assign period and phase shift of 97 degrees.
period = 1/97; % 97 hertz = period of 1/97 of a second.
phaseShift = 97 * pi/180; % In radians.
y = sin(2*pi*t/period - phaseShift));
plot(t,y, 'bo-', 'LineWidth', 2);
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
Of course with 97 periods across the screen of width 1920 pixels, you won't see much - it will be all smashed together horizontally. You might want to plot fewer periods.
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!