Display of nodal values of a matrix
4 ビュー (過去 30 日間)
古いコメントを表示
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.).
0 件のコメント
回答 (2 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Polygons についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!