When I plot f towards time amplitude is increasing I don't know why. It should be constant. what's wrong?

1 回表示 (過去 30 日間)
f(1)=10; %% Ratation angle (Rad)
w(1)=0; %% Angular velocity (Rad/sec)
E(1)=0; %% Angular acceleration
t(1)=0; %% Time vector (sec)
dt=0.001;
N=10000;
%% The main code
for i= 1:N
t(i+1)=t(i)+dt;
E(i)=-f(i);
w(i+1)=w(i)+E(i)*dt;
f(i+1)=f(i)+w(i)*dt;
end
plot(t,f);

採用された回答

Matt J
Matt J 2020 年 9 月 10 日
編集済み: Matt J 2020 年 9 月 10 日
I don't see why f should be constant, but nor is it monotonically increasing. Once I fix your initialization code, I see a sine-like wave:
clear
N=10000;
[f,w,E,t]=deal(zeros(1,N));
f(1)=10;
dt=0.001;
%% The main code
for i= 1:N
t(i+1)=t(i)+dt;
E(i)=-f(i);
w(i+1)=w(i)+E(i)*dt;
f(i+1)=f(i)+w(i)*dt;
end
plot(t,f);
  3 件のコメント
Matt J
Matt J 2020 年 9 月 10 日
Perhpas you meant to have,
f(i+1)=f(i)+w(i+1)*dt;
Nikoloz Nikuradze
Nikoloz Nikuradze 2020 年 9 月 10 日
You are right that helped a lot. Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by