フィルターのクリア

Display of nodal values of a matrix

2 ビュー (過去 30 日間)
Charles
Charles 2024 年 3 月 20 日
回答済み: Aquatris 2024 年 3 月 20 日
I made a code to calculate the temperature of nodes, compiled as a matrix, in a 2D space given set boundary temperatures. I was able to get a figure for a temperature contour but now I need to display the values in the matrix as a figure similar to how shown below (excluding T1, T2, etc.).

回答 (2 件)

Mario Malic
Mario Malic 2024 年 3 月 20 日
Here is a function that allows that text

Aquatris
Aquatris 2024 年 3 月 20 日
You can use patch and text functions:
nrRow = 4; % number of rows
nrCol = 6; % number of columns
recW = 0.5;% rectangle width
recH = 0.5;% rectangle height
temps = round(rand(21,1)*5000); % random temperature values
for i = 0:20
nodeName{i+1} = sprintf('T_{%d}',i+1); % name of node
pos(i+1,:) = [mod(i,nrCol) nrRow-floor(i/nrCol)]; % position of node
end
% rectangle x and y coordinates
x = [pos(:,1)'+recW/2
pos(:,1)'+recW/2
pos(:,1)'-recW/2
pos(:,1)'-recW/2];
y = [pos(:,2)'+recH/2
pos(:,2)'-recH/2
pos(:,2)'-recH/2
pos(:,2)'+recH/2];
figure(1)
clf
patch(x,y,'g') % draw rectangles
text(pos(:,1)-recW/4,pos(:,2),nodeName) % write node names
text(pos(:,1)-recW/2,pos(:,2)-recH/1.5,string(temps)+' K') % write temperature values

カテゴリ

Help Center および File ExchangePolygons についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by