位置 1 のインデックスが無効です。配列インデックスは正の整数または logical 値でなければなりません。
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
X = cat(2,Z,Y);
all = [];
all = zeros(1800000,6);
all(:,1) = 0.001:0.001:1800;
el = length(X);
for i = 2:el
a = X(i,1)/0.001;
all(a,2) = X(i,2);
end
というプログラムを実行すると、「位置 1 のインデックスが無効です。配列インデックスは正の整数または logical 値でなければなりません。」というエラーが出ます。0番目にアクセスしているわけではないのになぜこのようなエラーが出るのでしょうか?
なおall = 1800000×6 double, el = 1386で i=1の時a=1.6887e+04ですのでallの行を超えていません。
0 commentaires
Réponse acceptée
Atsushi Ueno
le 3 Juil 2021
配列のインデックスはエラーの表記通り「正の整数または logical 値でなければなりません」
Xの値が不明ですが、
a = fix(X(i,1)/0.001);
等としてaの値を整数値に丸めればエラーは解消します。
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!