Index exceeds array dimensions. Index value 100 exceeds valid range [1-99] of array D.

1 次查看(过去 30 天)
the number of elements appear correct but I get an error, why
i = Columns 1 through 22 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Columns 23 through 44 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Columns 45 through 66 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Columns 67 through 88 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 Columns 89 through 99 90 91 92 93 94 95 96 97 98 99 100 i = Columns 1 through 22 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Columns 23 through 44 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Columns 45 through 66 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Columns 67 through 88 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 Columns 89 through 99 90 91 92 93 94 95 96 97 98 99 100 i = Columns 1 through 22 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Columns 23 through 44 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 Columns 45 through 66 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 Columns 67 through 88 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 Columns 89 through 99 90 91 92 93 94 95 96 97 98 99 100
Index exceeds array dimensions. Index value 100 exceeds valid range [1-99] of array D. Error in 'simulacao_julio6/MALATB Function1' (line 9) dot_theta=(1/(2*dz))*((D(i+1)+D(i)).*(theta(i+1)-theta(i))/dz -(D(i-1)+D(i)).*(theta(i)-theta(i-1))/dz+(K(i)-K(i-1)));
Component:Stateflow | Category:Runtime error
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • Simulation stopped because of a runtime error.
this is my code
function dot_theta = Richards(theta,K,D,thetaz_0,thetaz_f)
L=1; %comprimento
z=linspace(0,L,100); % espaco de discretizacao
dz=L/length(z);
b=1/(2*dz^2);
i=max([1 0 2]):length(z),
dot_theta=(1/(2*dz))*((D(i+1)+D(i)).*(theta(i+1)-theta(i))/dz -(D(i-1)+D(i)).*(theta(i)-theta(i-1))/dz+(K(i)-K(i-1)));
%condicao de contorno1
%Se o indice do primeiro elemento do vetor for 1 em vez de 0, seria:
dot_theta(1)=dot_theta(1)+thetaz_0/dz;
%Condicao de contorno no ultimo elemento:
dot_theta(99)=dot_theta(99)-thetaz_f/dz;
  3 个评论
jose luis huayanay villar
yes, D
function D = fcn(theta)
L=1; %comprimento
z=linspace(0,L,100); % espaco de discretizacao
theta_r = 0.218; % conteudo de agua residual
alpha= 0.0115; %parametro de Van Genuchten 1/cm (Van Genuchten, 1980)
K_s = 31.6; % conductividade de saturacao cm/t
theta_s=0.52; %conteudo de agua saturado
n = 2.03;
m=1-(1/n);
i=max([1 0 2]):length(z),
D =(K_s*(1-m)/(alpha*m*(theta_s-theta_r)))*(theta(i-1).^(0.5-(1/m))./(1-(theta(i-1).^(1/m)))).*((1-(1-(theta(i-1).^(1/m))).^m).^2);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品


版本

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by