数组索引问题。
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clear all;
N = 20;
for i = 1 :N
A{i} = rand(5)
end
whos A
for j = 1:4
if j ==2|j== 4
B{j} = [A{5j};A{5j-1};A{5j-2};A{5j-3};A{5j-4}]
elseif j == 1|j ==3
B{j} = [A{5j-4};A{5j-3};A{5j-2};A{5j-1};A{5j}]
end
end
[size=13.3333px]出错 test (第 12 行) B{j} = [A{5j-4};A{5j-3};A{5j-2};A{5j-1};A{5j}]
[size=13.3333px]这里显示12行索引错了,但是我算了一下索引是大于0的整数啊
0 Kommentare
Akzeptierte Antwort
pongens
am 16 Mai 2023
请养成好习惯,不要误以为现实中的数学式写法能在MATLAB中也通用。
新手常见错误就有把必要的乘号省略、把圆括号方括号花括号乱用。
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!