フィルターのクリア

Integrate inside ode45, every value of a a vector

1 回表示 (過去 30 日間)
Ilias Minas
Ilias Minas 2020 年 3 月 1 日
コメント済み: darova 2020 年 3 月 1 日
Hi everyone,
I have the following part inside a script
if t<=1.5
x=(0:2.51326406981556e-05:2*pi)'; %limits for integration
.
.
.
for i=1:1:250001
Y=(((r.*cos(x)-y(5))-r.*cos(x)+y(6))./((((((r.*cos(x)-y(5))-r.*cos(x)+y(6))).^2+((r.*sin(x)-y(5))+r.*sin(x)).^2).^0.5))); % r is difined in the beginning of the script
Integral(i)=trapz(x,Y);
end
.
.
.
y(5)=y(6);
dy(6)=(-kr*(y(5)+L*y(11))+b*(-kr*(y(6)+L*y(12)))-0.36*Fload*Integral(i))/mcd; % Fload is defined in the beginning.
I want after every time step, which is 1e-5, to use the values of y(5) and y(6) in order to calculate the Integral(i) and use this value for the next calculation of y(5) and y(6).
Practically, i want to integrate every value of Y, which is a function of y(5), y(6), inside [0,2pi], and y(5) and y(6) to be calculated based on this integral.
Is this the correct way for doing this?
Thank you very much.

採用された回答

darova
darova 2020 年 3 月 1 日
no need of for loop
if t<=1.5
x=(0:2.51326406981556e-05:2*pi)'; %limits for integration
Y=(((r.*cos(x)-y(5))-r.*cos(x)+y(6))./((((((r.*cos(x)-y(5))-r.*cos(x)+y(6))).^2+((r.*sin(x)-y(5))+r.*sin(x)).^2).^0.5))); % r is difined in the beginning of the script
% C1 = r*cos(x) - y(5) + y(6) - r*cos(x);
% C2 = 2*r.*sin(x)-y(5);
% Y=C1./sqrt(C1.^2+C2.^2); % r is difined in the beginning of the script
IntegralY=trapz(x,Y);
end
Show the equations you use
  10 件のコメント
Ilias Minas
Ilias Minas 2020 年 3 月 1 日
Thats what i am taking...strange
darova
darova 2020 年 3 月 1 日
Here is what i have for tend=1.5e-02
dashed line: using trapz
solid line: integral=1

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePartial Differential Equation Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by