Hello, so I am trying to make a mesh of nodes that will scale according to mesh size. Here's the code I have so far:
%%Set Parameters
k = 10; %W/mK
h = 30; %W/m^2K
q_dot = 25000; %W/m^2
T_inf = 298.15; %Kelvin
T1 = 283.15; %Kelvin
T2 = 298.15; %Kelvin
prompt = 'n = ';
n = input(prompt) %Nodes numbering in x-dir.
nodes = 1:n*n; %Node numbers
%%Matrix Population
NT = zeros(length(nodes),1);
T = (n+1):n:nodes(end);
B = n:n:nodes(end);
L = (3*n+3):n:((n+3)+6*n);
M = (3*n+4):n:((n+4)+6*n);
for i=1:length(nodes)
if i==1
NT(i)=1; %Top-left corner
elseif i>1 && i<n
NT(i)=8; %Left edge
elseif ismember(i,T)
NT(i)=2; %Top edge
NT(T(end))=3; %Top-right corner
elseif i==nodes(end)
NT(i)=5; %Bottom-right corner
elseif i==n
NT(i)=7; %Bottom-left corner
elseif i>T
NT(i)=4; %Right edge
elseif ismember(i,B)
NT(i)=6; %Bottom Edge
elseif ismember(i,L)
NT(L)=10; %Area of heat generation, row 1
elseif ismember(i,M)
NT(M)=10; %Area of heat generation, row 2
else
NT(i)=9; %Adiabatic area
end
end
node_reshape = reshape(NT,n,n);
The problem child I'm dealing with are these two lines:
elseif ismember(i,L)
NT(L)=10; %Area of heat generation, row 1
elseif ismember(i,M)
NT(M)=10; %Area of heat generation, row 2
Those lines are supposed to create for me a rectangular 2x5 node grid which is where the heat generation will take place, at a specific location. And it does--for a mesh size of 10x10 (when you input n=10, according to the prompt). Unfortunately, when I try to scale up or down (like, for example, setting n=20 for a 20x20 grid), that 2x5 grid won't scale upwards in size, which is an issue because the project gets a zero percent score if the code can't handle a variable size. Thus, I need an alternate solution, and I don't know enough about MATLAB to figure out how to find it. I was hoping there might be someone here who might be able to make some suggestions about how I should go about this?
Thanks in advance.

 채택된 답변

KSSV
KSSV 2017년 10월 17일

0 개 추천

For meshing a rectangular/ square region with node numbers, you can have a look on this link: https://in.mathworks.com/matlabcentral/fileexchange/33731-meshing-a-plate-using-four-noded-elements?focused=5204259&tab=function

댓글 수: 1

Zachary McCormick
Zachary McCormick 2017년 10월 17일
Interesting! Wouldn't making use of that model mean throwing out the rest of the code I've already written, though? I'm not really jazzed about the idea of undoing hours' worth of work. I'm mostly just looking for an if statement that can replace the few lines I pointed out in the OP.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2017년 10월 17일

댓글:

2017년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by