필터 지우기
필터 지우기

How can I plot a multidimensional array?

조회 수: 15 (최근 30일)
Raúl Alonso Merino
Raúl Alonso Merino 2019년 1월 22일
댓글: Raúl Alonso Merino 2019년 1월 28일
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

채택된 답변

Walter Roberson
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
Walter Roberson 2019년 1월 28일
You can exchange to for phi then for theta without changing the rest.
Raúl Alonso Merino
Raúl Alonso Merino 2019년 1월 28일
Perfect, thank you so much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by