How to solve this question? Help :'(

2 ビュー (過去 30 日間)
raizo dono
raizo dono 2020 年 6 月 30 日
コメント済み: Rik 2020 年 6 月 30 日
Question 4 (20 marks)
Laplace’s equation: Determine the distribution of temperature in a rectangular plane section, subject to a temperature distribution around its edges as follows:
The section shape, the boundary temperature distribution section and two chosen nodes are shown in the figure.
The temperature distribution is described by Laplace’s equation. Solving this equation by the finite difference method to nodes 1 and 2 of the mesh shown in the figure. This gives
(233.33 +T2 + 0 100 - 4T1)/h^2 = 2
(333.33 + 250 + 0 + T1 - 4T2)/h^2 = 2
where and are the unknown temperatures at nodes 1 and 2, respectively, and
Rearranging these equations gives
[(-4&1@1&-4)][(T_1@T_2 )]=[(-333.33@-583.33)][(-4&1@1&-4)][(T_1@T_2 )]=[(-333.33@-583.33)]
Solving this equation, we have and .
If we require a more accurate solution of Laplace’s equation, then we must use more nodes and the computation burden increases rapidly. Write a MATLAB script to solve the Laplace’s equation for any number of nodes in a square domain only. Run your codes for number of nodes
  4 件のコメント
Rik
Rik 2020 年 6 月 30 日
What is your question? When I run your code I get an output.
You can find guidelines for posting homework on this forum here. Please use the tools explained on this page to make your question more readable and attach the ellipgen function as an m file.
raizo dono
raizo dono 2020 年 6 月 30 日
編集済み: raizo dono 2020 年 6 月 30 日
The ellipgen and Untitled5 file that I attached earlier is the halfway answer for the question. What I am trying to find is how to run codes for number of nodes n=50, 100 and 150. I cannot find any solution for this. Attached is the m file for the ellipgen

サインインしてコメントする。

採用された回答

Rik
Rik 2020 年 6 月 30 日
You should learn about the linspace function. I would also suggest you check if you have x and y correct. I kept your convention.
You were also limiting the axis so changing the number of nodes doesn't behave as expected.
Lx = 3; Ly = 2;
nx = 120; ny = 12; hx = Lx/nx; hy = Ly/ny;
by0 = linspace(0,Lx,nx+1); %by0 = 0*[0:hx:Lx];
byn = 200+(100/3)*linspace(0,Lx,nx+1).^2; %byn = 200+(100/3)*[0:hx:Lx].^2;
bx0 = 100*linspace(0,Ly,ny+1); %bx0 = 100*[0:hy:Ly];
bxn = 250*linspace(0,Ly,ny+1); %bxn = 250*[0:hy:Ly];
F = zeros(nx+1,ny+1); G = F;
a = ellipgen(nx,hx,ny,hy,G,F,bx0,bxn,by0,byn);
aa = flipud(a); colormap(gray)
surfl(aa)
xlabel('x direction')
ylabel('y direction')
zlabel('Temperature')
axis([0 nx 0 ny 0 500]) %axis([0 12 0 12 0 500])
  2 件のコメント
raizo dono
raizo dono 2020 年 6 月 30 日
So, how do I unlimit the axis to change the node numbers as asked in the question?
Rik
Rik 2020 年 6 月 30 日
I already edited that line for you. The only thing that is left for you is to figure out how you can run the same code with different inputs. Hint: use a for-loop, wrap your code in a function, or both.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by