フィルターのクリア

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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by