Azzera filtri
Azzera filtri

Arrange and Plot array values over time

18 visualizzazioni (ultimi 30 giorni)
Douglas Bowman
Douglas Bowman il 31 Gen 2022
Commentato: Star Strider il 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.

Risposte (2)

Star Strider
Star Strider il 31 Gen 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 Commento
Star Strider
Star Strider il 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.
.

Accedi per commentare.


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

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by