0

So I have a one dimensional vector in MATLAB that contains the interpolation of a pde solution over a meshgrid that I defined. I am solving a pde system for a cylinder, and what I want is to plot a contourslice at a given time. I can do this perfectly with the following code:

x = linspace(-0.06,0.06,100);
y = linspace(-0.06,0.06,100);
z = linspace(0,0.252,100);
[X,Y,Z] = meshgrid(x,y,z);
Tintrp = interpolateTemperature(result,X,Y,Z,12);
V=reshape(Tintrp,size(X));
contourslice(X,Y,Z,V,[],[],[0 0.05 0.1 0.15 0.2 0.252],40);

There, my meshgrid has the size of my cylinder (0.06 radius x 0.252 height), then I interpolate result (object from pde toolbox) at the index of 12, which represents a certain time. Then I adequate the interpolation to the size of my grid and I get the graph that I am looking for: Contourslice plot

Now, what I'd like to do is to threshold all the values in V that are greater than 0 and replace them with 0. For what I've read, I would accomplish that with:

V(V>0)=0;

But to my surprise, what happens when I insert that line of code before plotting is that somehow my volume gets "shrinked" and I see sort of the same figure that I attached above but the dimensions do not relate, here is the output: Contourslice plot

So it looks like it worked when you check the scale, but when you look at the axis then you notice something is off. What is also curious about this is that the higher the threshold I ask for (say, V(V>5)=5), the closer the shape gets to the first one. Does anybody have any idea on how to tackle this? Or if I am using any of the functions in the wrong way? Thanks! Leandro

  • What is the intended result? You want the axes to match the first image even though after thresholding the contours that use the full range of those axes no longer exist? – Will Nov 20 '19 at 14:44
  • The fact that they are 0-valued does not mean that they do not exist anymore, I expect to see the different colors in the middle, where values are less than 0, and for the outer regions I expect to see contours of the same color because they are all 0 valued now (they were greater than 0), after the threshold. – Yeymuffins Nov 20 '19 at 15:00
  • If there is a 0-valued contour in the first plot (and I'm not sure this is necessarily guaranteed - there may just be levels either side of 0) in the second plot this would not be a curve but a semi-finite patch. The extra circles in the first plot only exist as a result of the variation of `V` through `X`,`Y` and `Z` that you propose to remove. However you can certainly put a threshold on the colour scale applied to those contours, which would achieve what you seem to be describing. – Will Nov 20 '19 at 15:48

0 Answers0