How can I define the temperature in 2D domain at location x,y [rather than nodal locations] for steady state or transient solution?

1 次查看(过去 30 天)
I have been able to duplicate the results for the steady state and transient responses for the problem defined at
This example includes code to plot the temperature at a specific point in the block, in this case near the center of the right edge, as a function of time.
I would be interested to define the temperature and temperature history at any x,y location for the defined block with the slot in it- for example at the top right corner of the slot.

采纳的回答

Shishir Reddy
Shishir Reddy 2024-8-23
Hi John
Finding the temperature at an arbitrary point ((x, y)) within a finite element mesh can be challenging because directly calculating the temperature at a random (x, y) point would require identifying the element containing the point and using interpolation functions, which can be complex and computationally intensive.
Instead of calculating the temperature at the exact (x, y) point, it can be approximated to the temperature at the nearest node. This is an efficient approximation because it reduces the complexity and also gives closer estimate to the temperature if the mesh is sufficiently refined.
If observed closely, it can be understood that same method is followed in the documentation in finding the temperature at the centre of the right edge as well.
% Function to find the index of the nearest node
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
% Find the index of the nearest node
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would like to calculate the temperature at.
To find the temperature at top right corner of the slot, substitute x_target = 0.5 and y_target = 0.8.
I hope this helps.
  1 个评论
John McGrath
John McGrath 2024-8-23
Hi Shishir,
Thank you for your response. I tried your suggestion and got error messages as follows:
Undefined function 'minus' for input arguments of type 'matlab.graphics.GraphicsPlaceholder'.
Error in untitled78>@(p,x,y)find(min((p(1,:)-x).^2+(p(2,:)-y).^2)==(p(1,:)-x).^2+(p(2,:)-y).^2) (line 55)
getClosestNode = @(p, x, y) find(min((p(1,:) - x).^2 + (p(2,:) - y).^2) == (p(1,:) - x).^2 + (p(2,:) - y).^2);
Error in untitled78 (line 57)
nid = getClosestNode(p, x_target, y_target);% (x_target, y_target) are the coordinates of the specific position we would
like to calculate the temperature at.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by