필터 지우기
필터 지우기

Mesh/Contour Plot of Temperature Distribution

조회 수: 2 (최근 30일)
Jeremiah
Jeremiah 2013년 11월 11일
댓글: Jeremiah 2013년 11월 11일
I am attempting to solve the following problem:
x,y spacing=.2
Create a surface and contour plot of temperature distribution from the given data.
Given equations describe heat dist. in a flat square metal plate:
T(x,y)=(T2-T1)*w(x,y)+T1
where w(x,y)=(2pi) * (summation(n is odd, to infinity)((2/n) * sin((n*pi*x)/L)) * (sinh((n*pi*y/L)) / (sinh((n*pi*W)/L))
T1=3 sides held at constant of 70 degrees
T2=4th side held at constant of 200 degrees
W=L=2ft.
This is my current code and dilemma, with my current code the dimensions of x,y,T(temperature) have dimensions that are not compatible to graph using functions such as surf(x,y,t). Any insight or direction is greatly appreciated.
clc;
clear all;
T1=70;T2=200;L=2;W=2;i=0; %givens defined
for x=0:.2:2%for loop for W defined as x
i=i+1;%i increment of growth defined
j=0;%j initial defined
for y=0:.2:2 %for loop for L defined as y
j=j+1;%j increment of growth defined
error=100; Initial error defined
term=10*eps; Initial term defined(attempted to simulation term going to infinity)
n=1;% n initial defined
while abs(error)>.01%while loop defined as absolute value of error >1 percent
termnext=term+(2*pi)*(2/n)*(sin(n*pi*x)/L)*((sinh((n*pi*y)/L))/(sinh((n*pi*W)/L)));%Next term defined from previous term + the given equation.
if abs(error)~=0 %conditional statement revising error value when error ~=0
error=((termnext-term)/term)*100;
n=n+2; %n increment of growth defined as odd by adding 2 each cycle
end
end
end
end
t(x,y)=(T2-T1)*termnext+T1;%Given equation of t defined with substitution of (w(x,y)
surfc(x,y,t)% unsuccessful attempt at plotting x vs y vs t.

채택된 답변

Walter Roberson
Walter Roberson 2013년 11월 11일
surfc(0:.2:2, 0:.2:2, t)
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 11월 11일
When x or y are not integers, you cannot store into t(x,y).
xvals = 0 : 0.2 : 2;
yvals = 0 : 0.2 : 2;
for xidx = 1 : length(xvals)
x = xvals(xidx);
for yidx = 1 : length(yvals)
y = yvals(yidx);
......
w(xidx, yidx) = ....
end
end
T = (T2-T1) * w + T1;
surfc(xvals, yvals, T)
Jeremiah
Jeremiah 2013년 11월 11일
Tricky Tricky, thank you so much for your insight, I did not know the integers limitations. It explains why I would get unexpected sizes when viewing my workspace for the variable. This is a pretty strong/cool code!
Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by