Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Error with array bounds
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear Community,
I am creating a function and unfortunately I dont know why I am getting this error "Index in position 1 exceeds array bounds." Can you please help me?
function [ABD_dome_2] = mt_laminate(Nsection,neutral_axis,Nplies)
%% Input Material Data
%% Laminate - Aluminum 2219 T6 alloy
%Nplies = 1; %Number of plies
E = 73800; % Young's Modulus in [N/mm^2]
t2 = 4.8; % Half Thickness of the thickest segment of the tank in [mm]
t1 = 1.5; % Thickness of the thinnest segment of the tank in [mm]
t = [1.5,4.8,2];
%% Temperature Gradients - Tank + Reinforcement Cylindrical Shell
deltaT = 0;
nu = 0.33; % Poisson's ratio
Coefficient = E/(1-nu^2);
% C matrix (material coordinates)- reduced stiffness matrix
Q = Coefficient * [1,nu,0;nu,1,0;0,0,(1-nu^2)/(2*(1+nu))];
%% Classical laminar theory
T = 25; % Temperature in [°C]
a = 1;
% m = 3; To use it in case I need HIBEF
Ai = zeros(3,3);
% A = cell(Nsection,1);
% B = cell(Nsection,1);
% D = cell(Nsection,1);
Bi = zeros(3,3);
Di = zeros(3,3);
NTi = zeros(3,1);
MTi = zeros(3,1);
Qbari = zeros(3,3);
NT_plot =[];
nt_plot = zeros(3,1);
ABD = cell(Nsection,1);
for n = 1:Nsection
for m = 1:Nplies
if (t(n)/2 - neutral_axis ==0)
zbar(n) = 0 ;
A{n,:} = Ai + Q*t(n);
B{n,:} = Bi + Q * t(n) * zbar(n);
D{n,:} = Di + Q * (t(n) * zbar(n)^2 + t(n)^3 / 12);
ABD1 = {A{n,:},B{n,:};B{n,:},D{n,:}};
ABD11 = cell2mat(ABD1);
%ABD{1,:}= {A,B;B,D};
ABD{1,:} = ABD11;
else
zbar_up(n,:) = (t(n) - neutral_axis)/2;
t_up(n,:) = (t(n) - neutral_axis);
zbar_down(n,:) = (neutral_axis)/2;
t_down(n,:) = neutral_axis;
A_up{n,:} = Ai + Q * t_up(n,:);
B_up{n,:} = Bi + Q * t_up(n,:) * zbar_up(n,:);
D_up{n,:} = Di + Q * (t_up(n,:) * zbar_up(n,:)^2 + t_up(n,:)^3 / 12);
A_down{n,:} = Ai + Q * t_down(n,:);
B_down{n,:} = Bi + Q * t_down(n,:) * zbar_down(n);
D_down{n,:} = Di + Q * (t_down(n,:) * zbar_down(n,:)^2 + t_down(n,:)^3 / 12);
ABD_up{n,:} = {A_up{n,:},B_up{n,:};B_up{n,:},D_up{n,:}};
ABD_up_Matrix = cell2mat(ABD_up{n,:});
ABD_down{n,:} = {A_down{n,:},B_down{n,:};B_down{n,:},D_down{n,:}};
ABD_down_Matrix = cell2mat(ABD_down{n,:});
ABD{n,:} = ABD_up_Matrix - ABD_down_Matrix;
end
end
%% Differential System Matrix
ABD_cyl_15 = ABD{1,:};
ABD_cyl_48 = ABD{2,:};
ABD_dome_2 = ABD{3,:};
%% 1.5 mm cylindrical Segment
r_cyl = 550;
A_cyl_15 = [0, 1/r_cyl - ABD_cyl_15(1,2)/(ABD_cyl_15(1,1) *r_cyl),0,1/(ABD_cyl_15(1,1)*r_cyl),0,0,0;
1/r_cyl,0,1,0,0,0,0;
0,0,0,0,0,1/(ABD_cyl_15(4,4)*r_cyl),0;
0 , 0 , 0 , 0 , 1/r_cyl ,0,0;
0 , ABD_cyl_15(2,2)/r_cyl - ABD_cyl_15(1,2)*ABD_cyl_15(2,1)/(ABD_cyl_15(1,1)*r_cyl), 0,- (1/r_cyl) + ABD_cyl_15(2,1)/(ABD_cyl_15(1,1)*r_cyl),0,0,0.36;
0 , 0, 0, 0, -1, 0 ,0;
0,0,0,0,0,0,0];
for m = 1:90
A_15_cell{m,:} = A_cyl_15;
end
%% 4.8 mm cylindrical Segment
rho = 1100;
r_cyl = 550;
A_48_cell = cell(60,1);
A_48_cell{1,:} = zeros(7,7);
% A_cyl_48(1,1) = - ABD_cyl_48(2,1) * ABD_cyl_48(4,4) + ABD_cyl_48(2,4) * ABD_cyl_48(1,4);
%t2_a31 = - ABD_cyl_48(1,2)* ABD_cyl_48(1,4) + ABD_cyl_48(2,4)* ABD_cyl_48(1,1);
%
% t2_a41 = - ABD_cyl_48(2,1)*ABD_cyl_48(4,4)*ABD_cyl_48(1,2) + ABD_cyl_48(2,1)*ABD_cyl_48(1,4)*ABD_cyl_48(1,5) + ABD_cyl_48(2,4)*ABD_cyl_48(1,4)*ABD_cyl_48(1,2) - ABD_cyl_48(2,4)*ABD_cyl_48(1,5)*ABD_cyl_48(1,1);
% t2_a46 = - ABD_cyl_48(2,1)* ABD_cyl_48(1,4) + ABD_cyl_48(2,4)*ABD_cyl_48(1,1);
%
% det_t2 = - ABD_cyl_48(1,1)* ABD_cyl_48(4,4) + ABD_cyl_48(1,4)^2;
% A_cyl_48 = [0, 1/r_cyl - ABD_cyl_48(1,2)/(ABD_cyl_48(1,1)*r_cyl),0,1/(ABD_cyl_48(1,1)*r_cyl),0,-ABD_cyl_48(1,4)/(det_t2*r_cyl),0;
% 1/r_cyl,0,1,0,0,0,0;
% 0,-(t2_a31)/(r_cyl*det_t2),0,-ABD_cyl_48(1,4)/(r_cyl*det_t2),0,-ABD_cyl_48(1,1)/(r_cyl*det_t2),0;
% 0 , 0 , 0 , 0 , 1/r_cyl ,0,0;
% 0 , (ABD_cyl_48(2,2)/r_cyl - 1/(r_cyl*det_t2)*(t2_a41)), 0,- 1/rho + (1* t2_a11)/(r_cyl*det_t2) ,0,-((1*t2_a46)/(r_cyl*det_t2)),0.36;
% 0 , 0, 0 , 0, -1, 0,0;
% 0,0,0,0,0,0,0];
%
%
for i = 1:60
A_48_cell{i,:} =[0,1/r_cyl - ABD_cyl_48(1,2)/(ABD_cyl_48(1,1) *r_cyl),0,1/(ABD_cyl_48(1,1)*r_cyl),0,0,0;1/r_cyl,0,1,0,0,0,0;0,0,0,0,0,1/(ABD_cyl_48(4,4)*r_cyl),0;0 , 0 , 0 , 0 , 1/r_cyl ,0,0;0 , ABD_cyl_48(2,2)/r_cyl - ABD_cyl_48(1,2)*ABD_cyl_48(2,1)/(ABD_cyl_48(1,1)*r_cyl), 0,- (1/r_cyl) + ABD_cyl_48(2,1)/(ABD_cyl_48(1,1)*r_cyl),0,0,0.36;0 , 0, 0, 0, -1, 0 ,0;0,0,0,0,0,0,0];
end
end
0 comentarios
Respuestas (1)
Robert Mende
el 20 de Nov. de 2020
Would you please send the whole error message? It's problematic for anyone trying to help you find an error that might occur in any line that contains an array.
3 comentarios
Robert Mende
el 20 de Nov. de 2020
So your error appears within a part of the code that you commented out. Do you still need this part?
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!