我有一个数据文件,其中有3列用于x轴位置,另一列在时间上,第三列是温度。
因此,我对整个x和整个时间的温度进行了插值处理,从而使用splittedInterpolant获得了一个连续的插值多项式句柄。
然后,我在所有x和时间值上创建了一个网格,并在所有这些值上获得了插值多项式的值。
然后我在所有这些内插值上绘制等高线图。
但是我在这里看到了一些奇怪的行为。如您在图中所看到的,我的x值从10到1300之间不等。因此,如果我保留这些x值,到处都会看到蓝色区域。但是,当我将该范围减小到200-1300时,到处仍会看到相同的蓝色区域。即使我将其更改为任何其他值,如图所示的整个蓝色区域仍然保留。
所以我的问题是,我想在轮廓的顶部边界上方有一个白色区域,您可以看到该区域大约在1200左右,而在x轴上轮廓的尾部下方有一个类似的白色区域,大约在200左右或者。
但是我想将蓝色区域保持在轮廓停止的三角形区域,因为在时间轴(即x轴)上指定的不同时间比例下,x = 400-1200处存在材料。
PS:为清楚起见,y轴是x值,x轴是时间值,轮廓与z轴上的温度相对应,该温度是通过使用matlab中的splitInterpolant函数对x和时间进行插值而获得的。
这是我正在使用的脚本:
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);
请注意,图表开始的三角形区域现在是白色,之前是蓝色,我想保留该形状,但是我该怎么做呢?
我认为这是您要寻找的。如果不是,请告诉我。我只是说过,如果某个时间点或所有空间的温度始终超出范围,请忽略它。
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句