Display of nodal values of a matrix

5 visualizaciones (últimos 30 días)
Charles
Charles el 20 de Mzo. de 2024
Respondida: Aquatris el 20 de Mzo. de 2024
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.).

Respuestas (2)

Mario Malic
Mario Malic el 20 de Mzo. de 2024
Here is a function that allows that text

Aquatris
Aquatris el 20 de Mzo. de 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

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by