Hi there, i'm supposed to write a program that plots the function x(t) = cos(2*pi*t - theta) between the limits -1 > t > 1, and saves the handle of the resulting line. The angle theta is supposed to initially be 0 radians, and then, I need to re-plot line over and over with (theta = pi/10 rad), (theta = 2*pi/10 rad), (theta = 3*pi/10rad) and so forth up to (theta = 2*pi rad). I'm not sure how this is supposed to turn out, so this is what I have so far below. Can anyone help?
clc
clear all
for t_steps = 10 : 10 : 100
t = linspace(-1, 1, t_steps);
theta = 0; % or pi/10 or 2*pi
hlot = cos(2*pi*t - theta);
set(hlot, 'XData', t);
drawnow;
pause(1);
end
for t_steps = 10 : 10 : 100
t = linspace(-1, 1, t_steps)
theta = pi/10; % or pi/10 or 2*pi
xt = cos(2*pi*t - theta);
set(hlot, 'YDATA', t);
drawnow;
pause(1);
end

4 Kommentare

% Are you looking for this one, vary theta only
t=1:.1:10;
for n=0:100;
theta=n*pi/10;
hlot=cos(2*pi*t-theta);
plot(hlot);
hold on;
end
hold off;
Matt Amador
Matt Amador am 17 Nov. 2017
I plotted this, and I get a HUGE random mess of arrays and lines everywhere.. Is this what is supposed to happen?
KALYAN ACHARJYA
KALYAN ACHARJYA am 17 Nov. 2017
Bearbeitet: KALYAN ACHARJYA am 17 Nov. 2017
I have given the answer as per your question, reduce the increase the step size in t, and check again. Pls, vote the answer.
t=1:.5:10; % .1 replace with .5
Matt Amador
Matt Amador am 17 Nov. 2017
Okay, now I got it. Thanks!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

KALYAN ACHARJYA
KALYAN ACHARJYA am 17 Nov. 2017

0 Stimmen

clc;clear all;
t=1:.5:10; % reduce the steps, now more clear graphs visible
for n=0:100;
theta=n*pi/10;
hlot=cos(2*pi*t-theta);
plot(hlot);
hold on;
end
hold off;
% Is this are you looking for.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by