How do I subtract variable dimension arrays
显示 更早的评论
Right now I do this:
dx = dists(2:end,1,:) - dists(1:end-1,1,:);
dy = dists(2:end,2,:) - dists(1:end-1,2,:);
dz = dists(2:end,3,:) - dists(1:end-1,3,:);
where:
>>size(dists)
ans =
13 9 1159
I would like to do this where dists could be (13,9,1159,8) or an arbitrarily larger dimensions tacked on to the end. The two arrays I'm subtracting would always be the same size and the same particular slices would be subtracted. (as you can see, I'm just subtracting the 1st from 2nd, 2nd from 3rd, etc along three columns in three vector calcs)
How would I specify that for arbitrarily larger dimensions instead of an if statement on size and then ':', or ':,:', or ':,:,:', etc.?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!