0
    clear all; clc;
% Constants
width=12*0.0254; %Conversion: 1 inch = 0.0254 meters
thickness=0.5*0.0254;
length=16*0.0254;
gravity=9.81;
temp_i=293;
temp_r=293:473;
sigma=5.67*(10^-8);
temp_film=(temp_i+temp_r)/2; %Temp at convection boundary layer
beta=1./temp_film;
pr=0.713; %Prandtl number
v=15.09*(10^-6); %m^2/s
k=0.02564;
k_steel=60.5; 
cp_steel=460;
denstity_steel=7845;
volume=length*width*thickness;
area=2*length*width;
x=volume/area;

%% Calculations
Ra_bottom=(gravity.*beta.*(temp_r-temp_i).*(length.*(1./16))^3.*pr)./(v^2);
psi_Pr=(1+(.492./pr).^(9./16))^(-16./9);
Nu_bottom=0.68+0.503.*[(Ra_bottom.*psi_Pr).^(1./4)];
h_bottom=(k./length).*Nu_bottom;

%Initial values to set up loops and evaluate temp. change over time.
  i=0;
  t_bottom1=473; %Assume all parts of plate start at 200C
  t_middle1=473;
  t_top1=473;
  dt1=15;
  l=dt1;


%Evaluating temperature at bottom (t_bottom)
while t_bottom1 > 294 %294 is t_inf (20C) times 1.05 (21) in Kelvin (294K)
    i=i+1;
    l=l+dt1;
    h_bottom1=h_bottom(i)+sigma.*(t_bottom1.^4-temp_i^4)./(t_bottom1-temp_i); %Error Occurs here LINE: 41
    t_bottom1=(t_bottom1-temp_i).*exp(-h_bottom1.*dt1/(denstity_steel.*cp_steel.*volume))+293;
    y_bottom(i)=t_bottom1; %temp in K
    x_bottom(i)=l;
end 

エラー:

h_bottom(182) にアクセスしようとしました。numel(h_bottom)=181 であるため、インデックスが範囲外です。

Untitled9 のエラー (41 行目) h_bottom1=h_bottom(i)+sigma.*(t_bottom1.^4-temp_i^4)./(t_bottom1-temp_i);

これが発生する理由はわかっていますが、問題の解決に苦労しています。

4

2 に答える 2

0

それがOKかどうかはわかりませんが、定義すると

temp_r = 293:0.5:473;

の要素が 2 倍にh_bottomなるため、少なくともエラーは解消されます。ただし、基礎となる物理学がまだ意味があるかどうかを判断するのはあなた次第です。

于 2012-10-23T04:47:57.570 に答える
0

もちろん、エラーは is のh_botton(182)ときにアクセスするためsize(h_bottom,1)です181。while ループの条件を確認する必要があります (t_bottom1 は 298 です... その時点では、条件が満たされているので小さくはありません)、181 を超えることはありません。ここで何をしたいのか正確にはわかりません。しかし、問題はまさにそこにあります。

matlab コードでエラーが発生した場合、その行まで実行されているため、エラーの正確な瞬間に変数の値を実際に確認できます。そのためには、コマンド ラインに変数の名前を入力するか、ワークスペースを参照してください。これは大いに役立ちます。

于 2012-10-23T07:57:16.087 に答える