如何生成具有不同温度的磁盘的热图?
How to generate a heatmap of a disk having its different temperatures?
我在根据定义的图形生成热图时遇到了一些问题。
与磁盘相比,我正在研究两个表面(一个磁盘和一个可以建模为一维的圆柱体)之间接触点的温度。
我有3组数据,一组是圆盘的半径(r),另一组是接触点的角度(Theta),最后一组是发生摩擦的接触点的温度.
到目前为止,我能够在通过另一个程序获得的模拟中创建磁盘和差异点,这为我提供了之前的数据集。
我遇到麻烦的地方是当我想 link 获得它的温度并根据它的温度给它一个色标。我不知道如何建立这种关系。
正如我所说,这就是我所得到的,这只是模拟结果给出的点的定义。
Theta = xlsread('Laiton1.xlsx',1,'G2:G3381'); % Parameter turning angle
r = xlsread('Laiton1.xlsx',1,'C2:C3381'); % Parameter radius
Tsurf_d = xlsread('Laiton1.xlsx',1,'E2:E3381'); % Temperature on the surface
x = r*cos(Theta'); % parametrical transformation of (r,Theta) for the X axis
y = r*sin(Theta'); % parametrical transformation of (r,Theta) for the Y axis
Theta1 = linspace(0,360,5000); % Angle to define the 2 circumferences of the disk
x1 = 0.0145*cos(Theta1); % X points for the inner circumerference
y1 = 0.0145*sin(Theta1); % Y points for the inner circumerference
x2 = 0.0475*cos(Theta1); % X points for the external circumerference
y2 = 0.0475*sin(Theta1); % Y points for the external circumerference
plot(X,Y,X1,Y1,'black',X2,Y2,'black')
我希望我理解你的问题:你有三个坐标和测量向量,你想用它们绘制热图。下面的代码就是这样做的。改变参数 "resolution" 以放大或缩小绘图。
% Me simulating your data
numData = 100;
Theta = (0:2*pi/(numData-1):2*pi) + (rand(1,numData)-.5)/10;
r = 23 + (rand(1,numData)-.5);
Tsurf_d = rand(1,numData)*100;
% Creating a table on which you can gather your data for plotting
resolution = 1; % Smaller number -> bigger and fewer pixels
c = resolution*ceil(max(r)) + 1; % Which pixel will be your center coordinate
width = 2*c + 1; % The width and height of your table
tempSumMap = zeros(width);
numDataMap = zeros(width);
% Calculating corresponding positions of each data point
xCoords = round( resolution*r.*cos(Theta) );
yCoords = round( resolution*r.*sin(Theta) );
% Adding the data points. In situations where two data points want to add
% to the same pixel, they both add, and numDataMap remembers to later
% divide by 2
for dataNo = 1:numData
y = yCoords(dataNo) + c ;
x = xCoords(dataNo) + c ;
tempSumMap(y,x) = tempSumMap(y,x) + Tsurf_d(dataNo);
numDataMap(y,x) = numDataMap(y,x) + 1;
end
% Remember to divide by the number of times you added a certain temperature
% to a pixel
tempMap = tempSumMap./max(1,numDataMap);
% Display the result
imagesc(tempMap)
我在根据定义的图形生成热图时遇到了一些问题。 与磁盘相比,我正在研究两个表面(一个磁盘和一个可以建模为一维的圆柱体)之间接触点的温度。
我有3组数据,一组是圆盘的半径(r),另一组是接触点的角度(Theta),最后一组是发生摩擦的接触点的温度.
到目前为止,我能够在通过另一个程序获得的模拟中创建磁盘和差异点,这为我提供了之前的数据集。 我遇到麻烦的地方是当我想 link 获得它的温度并根据它的温度给它一个色标。我不知道如何建立这种关系。
正如我所说,这就是我所得到的,这只是模拟结果给出的点的定义。
Theta = xlsread('Laiton1.xlsx',1,'G2:G3381'); % Parameter turning angle
r = xlsread('Laiton1.xlsx',1,'C2:C3381'); % Parameter radius
Tsurf_d = xlsread('Laiton1.xlsx',1,'E2:E3381'); % Temperature on the surface
x = r*cos(Theta'); % parametrical transformation of (r,Theta) for the X axis
y = r*sin(Theta'); % parametrical transformation of (r,Theta) for the Y axis
Theta1 = linspace(0,360,5000); % Angle to define the 2 circumferences of the disk
x1 = 0.0145*cos(Theta1); % X points for the inner circumerference
y1 = 0.0145*sin(Theta1); % Y points for the inner circumerference
x2 = 0.0475*cos(Theta1); % X points for the external circumerference
y2 = 0.0475*sin(Theta1); % Y points for the external circumerference
plot(X,Y,X1,Y1,'black',X2,Y2,'black')
我希望我理解你的问题:你有三个坐标和测量向量,你想用它们绘制热图。下面的代码就是这样做的。改变参数 "resolution" 以放大或缩小绘图。
% Me simulating your data
numData = 100;
Theta = (0:2*pi/(numData-1):2*pi) + (rand(1,numData)-.5)/10;
r = 23 + (rand(1,numData)-.5);
Tsurf_d = rand(1,numData)*100;
% Creating a table on which you can gather your data for plotting
resolution = 1; % Smaller number -> bigger and fewer pixels
c = resolution*ceil(max(r)) + 1; % Which pixel will be your center coordinate
width = 2*c + 1; % The width and height of your table
tempSumMap = zeros(width);
numDataMap = zeros(width);
% Calculating corresponding positions of each data point
xCoords = round( resolution*r.*cos(Theta) );
yCoords = round( resolution*r.*sin(Theta) );
% Adding the data points. In situations where two data points want to add
% to the same pixel, they both add, and numDataMap remembers to later
% divide by 2
for dataNo = 1:numData
y = yCoords(dataNo) + c ;
x = xCoords(dataNo) + c ;
tempSumMap(y,x) = tempSumMap(y,x) + Tsurf_d(dataNo);
numDataMap(y,x) = numDataMap(y,x) + 1;
end
% Remember to divide by the number of times you added a certain temperature
% to a pixel
tempMap = tempSumMap./max(1,numDataMap);
% Display the result
imagesc(tempMap)