2012-10-23 3 views
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 

가 오류 :MATLAB : 인덱스가 경계 오류에서

이 h_bottom (182)에 액세스하려고 시도; numel (h_bottom) = 181이므로 인덱스가 범위를 벗어납니다.

Untitled9 (41 행)의 오류 h_bottom1 = h_bottom (i) + 시그마. * (t_bottom1.^4-temp_i^4) ./ (t_bottom1-temp_i);

왜 이런 일이 발생하는지 알고 있지만 문제를 해결하는 데 어려움이 있습니다.

답변

0

물론 size(h_bottom,1)181 일 때 h_botton(182)에 액세스하기 때문에 오류가 발생합니다. while 루프의 조건을 확인해야합니다 (t_bottom1은 298입니다. 그 순간에 조건이 충족 될 수 있도록 작아서), 결코 181을 초과하지 않습니다. 정확히 무엇을 원하니? 여기에 문제가 정확히 존재합니다.

matlab 코드에서 오류가 발생하면 해당 행까지 실행되었으므로 오류의 정확한 순간에 실제로 변수의 값을 볼 수 있습니다. 이를 위해서는 명령 행에서 변수의 이름을 입력하거나 작업 공간을보십시오. 이것은 당신을 많이 도울 것입니다.

0

나는 그것을 할 할 수있는 상태인지 모르겠지만, 당신이

temp_r = 293:0.5:473; 

을 정의 할 경우 적어도 오류가 멀리 갈 수 h_bottom에서 두 배나 많은 요소를해야합니다. 그러나 기본 물리학이 여전히 이치에 맞는지 여부를 결정하는 것은 당신에게 달려 있습니다.

관련 문제