How can I plot a multidimensional array?
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-1-22
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 个评论
Walter Roberson
2019-1-28
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!