How do I access and plot thetadot vs. time from function I have created?

4 ビュー (過去 30 日間)
function thetadot= oscltr(t,theta)
A= [0 0 0.5 0 0 0; 0.5 0 0 0 0 0.5; 0.5 0.5 0 0 0 0; 0 0.5 0 0 0 0; 0 0 0.5 0 0 0; 0 0 0 0.5 0.5 0]; % edge weight matrix
D= [0.5 0 0 0 0 0; 0 1 0 0 0 0; 0 0 1 0 0 0; 0 0 0 0.5 0 0; 0 0 0 0 0.5 0; 0 0 0 0 0 1]; %Diagonal in-degree matrix
L= D-A; %Laplacian matrix
N=6;
K=50;
wi=[1; 1.1 ;0.9; 0.85; 2; 2.1];
thetadot=wi-(K/N)*L*theta;
end

採用された回答

Walter Roberson
Walter Roberson 2022 年 10 月 8 日
Please see my response at https://www.mathworks.com/matlabcentral/answers/1818985-how-to-work-variables-outside-function#answer_1068360 discussing why it is unlikely that you want to access the internal variables computed by an ode function: such a record would have far too many entries and would also not have entries for most of the time steps.
  1 件のコメント
Shlok Pravinbhai Kansara
Shlok Pravinbhai Kansara 2022 年 10 月 8 日
編集済み: Shlok Pravinbhai Kansara 2022 年 10 月 8 日
Thanks @Walter Roberson, I believe, I resolved it using your commnet of gradient().

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

その他の回答 (1 件)

Ghazwan
Ghazwan 2022 年 10 月 8 日
編集済み: Walter Roberson 2022 年 10 月 8 日
There are several ways, one of whith would be
Dtheta=diff(theta) %theta = values
Dtime=diff(time) %time = time values.
ThetaDot = Dtheta./Dtime.
plot(Dtheta,time) % you have to be careful in case there is 0/0 somewhere.
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 10 月 8 日
I recommend using gradient() instead. The timestep for ode45 is typically irregular.
Torsten
Torsten 2022 年 10 月 8 日
Just call the function with the values for theta of your choice.

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

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by