필터 지우기
필터 지우기

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 CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by