How can I plot a multidimensional array?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Raúl Alonso Merino
am 22 Jan. 2019
Kommentiert: Raúl Alonso Merino
am 28 Jan. 2019
Hello, I want to create a gif from the data inside a 32x360x360 double array. The thing is I want to plot the 32 values for each 360x360, I mean plotting first 32x1x1, then 32x1x2, 32x1x3, 32x1x4, ..., 32x1x360, 32x2x1, 32x2x2, and so on making a gif until it reaches 32x360x360. Can this be done?
The next code is one I have if the vector was 32x129600. How can I change it to plot the other vector of one more dimension without reshaping it? As I would like to have a title for the gif with something like i = 1,2,3,4,...360 and j=1,2,3,4,...360 to see how it changes.
for i=1:JN
plot(Vector(:,i), 'k-', 'LineWidth', 2);
axis([startpoint finishpoint miny maxy])
xlabel('Time(s)')
ylabel('Relative Brightness')
grid on
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Write to the GIF File
if i == 1
imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'DelayTime',0.1);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.1);
end
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 22 Jan. 2019
Make JN = (360*360) .
When you index with fewer indices than there are dimensions, then the last index acts like a linear index relative to that dimension and later. So Vector(:,360) would correspond to Vector(:,360,1) and Vector(:,361) would correspond to Vector(:,2,1)
7 Kommentare
Walter Roberson
am 28 Jan. 2019
You can exchange to for phi then for theta without changing the rest.
For creating a video see https://www.mathworks.com/help/matlab/ref/videowriter.html#busy5fx-2
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!