Arrange and Plot array values over time

23 Ansichten (letzte 30 Tage)
Douglas Bowman
Douglas Bowman am 31 Jan. 2022
Kommentiert: Star Strider am 4 Feb. 2022
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.

Antworten (2)

Star Strider
Star Strider am 31 Jan. 2022
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 Kommentar
Star Strider
Star Strider am 4 Feb. 2022
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.
.

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by