필터 지우기
필터 지우기

How can i implement u1(i)- u2(i) in the while loop instead of u(i) and plot the graph against that too instead of u

조회 수: 2 (최근 30일)
close all;
dt = 0.464;%time step
u=1;
k=0.12;
m=2.21;%initial parameters
v=1;
a=1.4;
tend=100;
t=0;
i=1
while t < tend-2*dt
vh=v(i)-dt*k*u(i)/ (2*m);
u(i+1)= u(i)+ dt*vh;
a(i+1)= -k*u(i+1)/2;
v(i+1)= vh + dt*a(i+1)/2;
i = i+1;
t = t + dt
end
plot(linspace(0,tend,tend/dt),u);
  댓글 수: 2
Jan
Jan 2019년 6월 24일
There is no u1 or u2 in your code. I cannot guess, how you want to implement it, if you do not explain the details.
Advait Sinha
Advait Sinha 2019년 6월 24일
so i want to replace the u with u1 and u2. and then in the while loop instead of having vh = v(i)-dt*k*u(i)/(2*m) , I want to have vh = v(i) - dt*k*(u1(i)-u2(i))/(2*m) followed by the necessary changes

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by