Display of nodal values of a matrix
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Aquatris
am 20 Mär. 2024
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 Kommentare
Siehe auch
Kategorien
Mehr zu Polygons finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!