Help with updating slice plot in for loop

조회 수: 2 (최근 30일)
Jordan Clark
Jordan Clark 2018년 4월 17일
댓글: Adalric Leung 2020년 7월 5일
I am plotting slices of a block with dimensions x,y,z and using a colour map to represent the temperature of the block, which is described by the 3D-matrix, V, which is the temperature at each data point. The temperature changes over time so I am trying to create an animation using a for loop over time and drawnow.
The problem I have is that I cannot seem to access and change V. I need to implement something to effect of:
if true
[X, Y, Z] = meshgrid([0 x], [0 y], [0 z])
h = slice(X,Y,Z,V,xslice,yslice,zslice)
colorbar
for n = 1:tmax
Vnew = (function that determines the temperature at the next time step)
set(h, V, Vnew)
drawnow
end
end
I then get an error that says "There is no V property on the Surface class."
A workaround I have is to re-plot the whole graph at each step but this is quite slow - any help would be hugely appreciated!

답변 (1개)

Wick
Wick 2018년 5월 2일
You just need to draw a new slice with the new V_new.
if true
[X, Y, Z] = meshgrid([0 x], [0 y], [0 z]);
h = slice(X,Y,Z,V,xslice,yslice,zslice);
colorbar
for n = 1:tmax
Vnew = (function that determines the temperature at the next time step)
h = slice(X,Y,Z,Vnew,xslice,yslice,zslice);
drawnow
end
end
  댓글 수: 1
Adalric Leung
Adalric Leung 2020년 7월 5일
Hi I'm want to acheive the same thing as the previous person where my block dimensions are:
x = -0.5:dx:0.5; % x-vector (cm)
y = -0.5:dy:0.5; % y-vector (cm)
z = -0.5:dz:0.5; % z-vector (cm)
My temperature matrix is given by a 4D matrix (in x, y, z, time) where the first 3 terms provide the temperature at that location, creating a 3D temperature matrix at a sepcific time. I want to plot the block with those dimensions and then represent the changes in temperature as a colour, but I'm unsure how to interpret the code you wrote since I"m still fairly new to MatLab. More specifically, would the "V" be the 3D temperature matrix at a specific point in time? How would I get the x,y, and z slices?
I've included the data for my 4D temperature matrix if it helps.
Thank you for your time.

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by