could you please help to solve this question?
1 view (last 30 days)
Show older comments
The 10 𝑚 × 10 𝑚 titanium plate with a thermal conductivity of k=17 W/mK and thermal diffusivity of 𝛼=9.843 mm2 /s is shown above. At the boundaries, temperatures are as given below: x=0, 𝑇 = 150°𝐾 y=0, 𝑇 = 250°𝐾 x=10, 𝑇 = 390°𝐾 y=10, 𝑇 = 390°𝐾 Write a code to plot the temperature distribution as contour plot using
1. Jacobi Method
2. Gauss-Siedel Method
3. Successive Overrelaxation Method
4. Successive Line Overrelaxation Method
Solve the problem with each method for two cases: a. ∆𝑥 = ∆𝑦 = 0.1 𝑚 b. ∆𝑥 = 0.1𝑚, ∆𝑦 = 0.05
I wrote this code for Gauss-Shield but it is giving end error not only for end do but also while using just end. What is wrong?
dx = 0.1;
dy = 0.1;
dt = 1;
x=0:dx:10;
y=0:dy:10;
y=1:300;
n= numel(x);
T(1,1:n,t)=390;
T(n,1:n,t)=250;
T(1:n,1,t)=150;
T(1:n,n,t)=390;
T(2:n-1,2:n-1,1)=100;
k = 17;
alpha = 9.843*10^(-6); rho_cp = k/alpha;
A = zeros(n*n);
C = zeros(n*n,1);
T(1:n*n,1) = 300;
residual = 100;
iterations = 0;
while (residual > 0.0001)
iterations = iterations+1;
Told = T;
T(i,j,t)=((1-w)*T^k(i,j,t))+((w/4)*(T^k(i+1,j,t)+(T(i-1,j,t))^(k+1)+(T(i,j-1,t))^(k+1)+T^k(i,j+1,t)))
do while (Etot.le.Etol)
do x=(2,n-1)
do y=(2,m-1)
T(i,j)=(1-w)+((w/4)*(T(i+1,j)+T(i-1,j)+T(i,j-1)+T(i,j+1)))
end do
end do
end do
contour(T_10)
0 Comments
Accepted Answer
Image Analyst
on 12 Sep 2021
Edited: Image Analyst
on 12 Sep 2021
There is no "do" statement in MATLAB. There is a "while" and a "for" but no "do while" or "end do".
For example
do while (Etot.le.Etol)
% code
end do
would be
while Etot <= Etol
% Code
end
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!