How to plot harmonic motion in Matlab??

조회 수: 32 (최근 30일)
Hannah Dietz
Hannah Dietz 2018년 3월 6일
댓글: DGM 2023년 10월 22일
Plot harmonic motion of x in time, as described by the following equation x(t)=Acos(wt + phi) In this equation, A is the amplitude of the motion, w is the angular frequency, and phi is the phase shift, all of which are defined by the user.
and then when another harmonic motion in the y direction is also present: y(t)= Bcos(2wt - phi)
  댓글 수: 2
Jada
Jada 2023년 10월 22일
Where is the code for this question?
DGM
DGM 2023년 10월 22일
Not only is the answer sitting there plain as day, there were literally two duplicate copies of it.

댓글을 달려면 로그인하십시오.

채택된 답변

Abraham Boayue
Abraham Boayue 2018년 3월 7일
N = 200;
phi = pi/4;
A = 1;
B = 1;
t0 = -2;
tf = 2;
t = t0:(tf-t0)/(N-1):tf;
w = pi;
x = A*cos(w*t+phi);
y = B*cos(2*w*t-phi);
plot(t,x,'linewidth',3,'color','r')
grid
hold on
plot(t,y,'linewidth',3,'color','b')
a = title('Harmonic motion of phase \phi = \pi/4');
set(a,'fontsize',14);
a = ylabel('y(t), x(t)');
set(a,'Fontsize',14);
a = xlabel('t [-2 2]');
set(a,'Fontsize',14);
legend('x(t)', 'y(t)')
  댓글 수: 1
Abraham Boayue
Abraham Boayue 2018년 3월 7일
Hi Hanna, I hope you find this code useful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by