Index loop into matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi
Im very new to MatLab.
Im trying to get this loop to produce a 10x3 matrix and not 10 sepperate answers.
triCoord=10x9
ntri = 10
qTop = zeros(ntri,3)
for n=1:ntri
qTop =[]
qTop(n,:) = [qTop
mean(triCoord(n,[1 4 7])),mean(triCoord(n,[2 5 8])),mean(triCoord(n,[3 6 9]))]
end
qTop
0 个评论
采纳的回答
VBBV
2020-12-2
triCoord= zeros(10,9);
ntri = 10
qTop = zeros(ntri,3);
for n=1:ntri
qTop(n,:) = [mean(triCoord(n,[1 4 7])),mean(triCoord(n,[2 5 8])),mean(triCoord(n,[3 6 9]))];
end
qTop
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!