フィルターのクリア

Arrange and Plot array values over time

19 ビュー (過去 30 日間)
Douglas Bowman
Douglas Bowman 2022 年 1 月 31 日
コメント済み: Star Strider 2022 年 2 月 4 日
Given a 24x24x1202 array D, I'd like to plot each value. It's hard to explain what I want to do so I've attached a graphic. I'd like to plot each row of D, i.e. 576 plots of 1202 time samples.
Here's what I've tried:
for x=1:24
for y=1:24
for k=1:576
for j=1:1202
C(k,j)=D(x,y,j)
end
end
end
end
I've tried to re-arrange the for loops to no avail. I've really struggled on how to do this. Building the matrix is real challenge for me. I've included an image that helps explain what I'm trying to do. Can someone help? It would be much appreciated.

回答 (2 件)

Star Strider
Star Strider 2022 年 1 月 31 日
One approach —
M = rand(24,24,5); % Example Matrix
figure
hold on
for k = 1:size(M,3)
surf(M(:,:,k)*k/2+10*k)
end
hold off
grid on
view(30,30)
xlabel('X')
ylabel('Y')
zlabel('Time \rightarrow')
.
  1 件のコメント
Star Strider
Star Strider 2022 年 2 月 4 日
Using my code, the two-dimensional case would be something like one of these —
M = rand(24,24,5); % Example Matrix
figure
hold on
for k = 1:size(M,3)
plot(M(:,:,k)*k/2+10*k)
end
hold off
grid on
xlabel('Time \rightarrow')
ylabel('Y')
figure
hold on
for k = 1:size(M,3)
plot(reshape(M(:,:,k)*k/2+10*k, 1, []))
end
hold off
grid on
xlabel('Time \rightarrow')
ylabel('Y')
These began as random matrices, so there is no particular structure or definition to them otherwise. Experiment with your vectors and these approaches to get the result you want. The reshape and permute functions could be hepful here, however it may take some experimentation with them to get the result you want.
.

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


Douglas Bowman
Douglas Bowman 2022 年 2 月 3 日
I was thinking something like this in 2 dimensions. I having trouble understanding how to write code for it.

カテゴリ

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

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by