0
votes

I have a data file which has got 3 columns one for position on x axis, the other one in time and the third one is temperature.

So, I interpolated the temperatures throughout my x and time to obtain a continuous interpolating polynomial handle using scatteredInterpolant.

Then I created a mesh over all my x and time values and obtained the value of interpolated polynomial over all these values.

And then I plotted the contour plot over all these interpolated values.

But I am seeing a bit strange behavior over here. As you could see in the figure my x values vary from 10 to some 1300. So if I keep these x values I see the blue region everywhere. But when I reduce this range to 200-1300 I still see the same blue region everywhere. And even if I change it to any other value the entire blue region as shown in the figure still remains.

So my problem is this, I want to have white region above the top boundary of my contour which you could see is somewhere around 1200 and a similar white region below the trailing tail of the contour on the x axis which is somewhere around may be 200 or so.

But I want to keep the blue region in that triangular zone at which the contour stops because there is material there at x=400-1200 at different time scales specified on the time axis i.e. the x axis.

P.S.: Just for clarity the y-axis is x values, the x-axis is time values and the contour corresponds to temperature on the z-axis obtained by interpolating the x and time using scatteredInterpolant function in matlab.

This is the script which I am using:

clear all; close all; clc;
load temperature.txt;
time = temperature(:,1);               % This column contains the time
x = temperature(:,2);                  % This column contains the x values.
temperature_system = temperature(:,3); % This column contains the temperatures.

pos = temperature_system < prctile(temperature_system,41.967695);
time(pos) = [];
x(pos) = [];
temperature_system(pos) = [];

pos = (temperature_system > prctile(temperature_system,97));
time(pos) = [];
x(pos) = [];
temperature_system(pos) = [];

X1 = [time x];


F = scatteredInterpolant(X1,temperature_system);
x1 = linspace(min(x),max(x),100);
x2 = linspace(min(time),max(time),100);
[X,Y] = meshgrid(x2,x1);
Z = F(X,Y);
% plot3(x1,x2,F(x1,x2));
f1 = figure(1);
set(f1,'renderer','zbuffer');
%surf(X,Y,Z);
%ezcontourf(F)
[C,h] = contourf(X,Y,Z);
shading flat;
colormap(jet);
q = colorbar;
% cmap = colormap;
% cmap(1,:) = [1,1,1];
% colormap(cmap);

This is my figure without any modification: enter image description here

And this is my picture if I remove the blue region with white region.enter image description here

Please note the triangular zone at which the graph starts which is white now and was blue earlier, I want to keep this but how can I do that?

1

1 Answers

1
votes

enter image description hereI think this is what your looking for. Please let me know if it's not. I just said if the temperature is out of range for all time at a point or all space in an instant, ignore it.

function StackOverflow

%Setting up variables, since I don't have the data
x = 1300*rand(1500, 1);
t = 45*rand(size(x));
T = 3000*exp(-((x - 650).^2/(2*(650/3)^2)) - ((t - 22.5).^2/(2*(22.5/3)^2)));

%Some criteria for ignoring below
TLow = 500;

%Create the interpolant on a regular grid
F = scatteredInterpolant([t, x], T);
xr = linspace(min(x),max(x),100);
tr = linspace(min(t),max(t),100);

[tr,xr] = meshgrid(tr,xr);
Tr = F(tr,xr);

%Is the data below the criteria for all points in space at a specific time
emptyTime = all(Tr < TLow,1);

%Is the data below the criteria for all time at a point in space
emptySpace = all(Tr < TLow, 2);

%If there is no data set it to nan
[emptyTime, emptySpace] = meshgrid(emptyTime, emptySpace);
Tr(emptyTime | emptySpace) = nan;

%Do plotting stuff
f1 = figure(1);
set(f1,'renderer','zbuffer');

[C,h] = contourf(tr,xr,Tr);
shading flat;
colormap(jet);
q = colorbar;

end