【问题标题】:How to generate a heatmap of a disk having its different temperatures?如何生成具有不同温度的磁盘的热图?
【发布时间】:2018-05-23 11:55:43
【问题描述】:

给定一个定义的数字,我在生成热图时遇到了一些问题。 我正在研究两个表面(圆盘和圆柱)之间接触点的温度,与圆盘相比,可以将其建模为一维。

我有 3 组数据,1 组是圆盘的半径 (r),另一组是接触点的角度 (Theta),最后一组是发生摩擦的接触点的温度。

到目前为止,我能够在通过另一个程序获得的模拟中创建磁盘和不同点,这给了我以前的数据集。 我遇到的麻烦是当我想将获得的温度与它的点联系起来并根据它的温度给它一个色标时。我不知道如何建立这种关系。

正如我所说,这就是我得出的结论,这只是模拟结果给出的点的定义。

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')

【问题讨论】:

标签: matlab matlab-figure heatmap disk temperature


【解决方案1】:

我希望我正确理解了您的问题:您有三个坐标和测量向量,并且您希望用这些向量绘制热图。下面的代码就是这样做的。改变参数“分辨率”以放大或缩小绘图。

% 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)

【讨论】:

  • 谢谢,这很有帮助。我会尝试从这里解决。
猜你喜欢
  • 2017-11-26
  • 1970-01-01
  • 2020-06-27
  • 1970-01-01
  • 2023-03-14
  • 2015-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多