Borrar filtros
Borrar filtros

Arrange and Plot array values over time

19 visualizaciones (últimos 30 días)
Douglas Bowman
Douglas Bowman el 31 de En. de 2022
Comentada: Star Strider el 4 de Feb. de 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.

Respuestas (2)

Star Strider
Star Strider el 31 de En. de 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 comentario
Star Strider
Star Strider el 4 de Feb. de 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.
.

Iniciar sesión para comentar.


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

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by