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

2 ビュー (過去 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 Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by