hello I am getting this warning: Index in position 1 is invalid. Array indices must be positive integers or logical values. Error in dev4 (line 121)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Cedrick De Block
le 9 Déc 2021
Commenté : Cedrick De Block
le 9 Déc 2021
close all
% Données
k1 = 50;
k2 = 500;
M_c = 864.4; % Mass of the cabin
n_b = 3; % Number of blade
M_b = 33.9 * n_b; % Mass of the blades
M_E = 100; % Mass of the engine
M_h = 20; % Mass of horizontal tailplane
M_bt = 14; % Mass of the tail rotor blades (as rigid body)
M_v = 15; % Mass of the vertical tailplane
x_D = 1.8;
x_G = 6;
x_F = 3;
x_C = 2.5;
h_c = 0.3049;
h_E = 0.85;
h_b = 1.7;
J_yc = 2113;
J_zb = 918 ;
J_yh = 6.7 ;
J_yt = 1.31 ;
J_yv = 8.5;
l = 6;
m = 9.82; % Masse par unité de longueur de la queue
I_y = 1.7521 * 10^(-5);
E = 7*10^(10);
freq = load('P2021_freqz');
modes = load('P2021_modes_z');
% Méthode de Rayleigh-Ritz
% On va construire les matrices M et K avec les formules de m_ij et k_ij
n = 22; % Nombre de fonctions d'essais w_i
M = zeros(n);
K = zeros(n);
for j = 0 : n
for i = 0 : n
term1_m = (m*l^(i+j+1))/(l^(i+j)*(i+j+1));
if (i == 1 && j == 1)
term2_m = J_yc/l^2;
else
term2_m = 0;
end
if (i == 1 && j == 1)
term3_m = M_c * x_c^2/l^2;
else
term3_m = 0;
end
if (i == 0.5 && j == 0.5)
term4_m = M_c * x_c/2*l;
else
term4_m = 0;
end
if (i == 0.5 && j == 0.5)
term5_m = M_c * x_c/2*l;
else
term5_m = 0;
end
if (i == 1 && j == 1)
term6_m = M_c * h_c^2/l^2;
else
term6_m = 0;
end
if (i == 1 && j == 1)
term7_m = M_c * h_E^2/l^2;
else
term7_m = 0;
end
if (i == 1 && j == 1)
term8_m = J_yb /l^2;
else
term8_m = 0;
end
if (i == 1 && j == 1)
term9_m = M_b * x_D^2/l^2;
else
term9_m = 0;
end
if (i == 0.5 && j == 0.5)
term10_m = M_b * x_D/2*l;
else
term10_m = 0;
end
if (i == 0.5 && j == 0.5)
term11_m = M_b * x_D/2*l;
else
term11_m = 0;
end
if (i == 1 && j == 1)
term12_m = M_b * h_b^2/l^2;
else
term12_m = 0;
end
term13_m = M_h*(x_F/l)^(i+j);
term14_m = J_yh*i*j*((x_F)^(i+j-2)/l^(i+j));
term15_m = M_bt*(x_G/l)^(i+j);
term16_m = J_yt*i*j*((x_G)^(i+j-2)/l^(i+j));
term17_m = M_v*(x_G/l)^(i+j);
term18_m = J_yv*i*j*((x_G)^(i+j-2)/l^(i+j));
M(i,j) = term1_m + term2_m + term3_m + term4_m + term5_m + term6_m + term7_m + term8_m + term9_m + term10_m + term11_m + term11_m + term12_m + term13_m + term14_m + term15_m + term16_m + term17_m + term18_m;
end
end
for j = 0 : n
for i = 0 : n
if(i > 2 && j > 2)
term1_k = E*I_y*i*j*(i-1)*(j-1)*(l^(i+j-3)) / ((l)^(i+j) * (i+j-3)) ;
else
term1_k = 0;
end
if (i == 1 && j == 1)
term2_k = k1*x_D^2/l^2;
else
term2_k = 0;
end
if (i == 0.5 && j == 0.5)
term3_k = k1 * x_D/2*l;
else
term3_k = 0;
end
if (i == 0.5 && j == 0.5)
term4_k = k1 * x_D/2*l;
else
term4_k = 0;
end
if (i == 1 && j == 1)
term5_k = k2/l^2;
else
term5_k = 0;
end
K(i,j) = term1_k + term2_k + term3_k + term4_k + term5_k;
end
end
1 commentaire
Image Analyst
le 9 Déc 2021
You forgot to attach the .mat files.
freq = load('P2021_freqz');
modes = load('P2021_modes_z');
so I can't run your code. In the meantime, see the FAQ:
Réponse acceptée
Voss
le 9 Déc 2021
Indexing in MATLAB starts at 1, not 0.
Your loops iterate starting with 0 and then try to use that as an index, hence the error.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!