フィルターのクリア

Plotting the element of a 3D array

4 ビュー (過去 30 日間)
Yokuna
Yokuna 2022 年 11 月 11 日
回答済み: Walter Roberson 2022 年 11 月 11 日
The dimension of F is 2x2x145 (3D array), i.e. we have 145 number of 2x2 matrices. Now I want to find a vector having the (1,1)th element of all the matrices. How to obtain such vector having the (1,1)th element of all the matrices and then plot it with respect to time (T)?
M1 = [2 0;0 2];
odefun = @(t,y) part_a(t,y,M1);
[T,F] = ode45(odefun,[10 0],[2 0;0 2]);
F = reshape(F.',2,2,[]);
plot(T,F(1,1,:))
Error using plot
Data cannot have more than 2 dimensions.
function dy = part_a(t,y,M1)
F = reshape(y,size(M1));
FA = -M1*F;
dy = FA(:);
end

採用された回答

Walter Roberson
Walter Roberson 2022 年 11 月 11 日
plot(T, squeeze(F(1,1,:)))

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by