How to make specific elements in a 3D matrix zero?
显示 更早的评论
Hi I have a 3D matrix namely Costyearlydata having size of 24x365x10 and I want to make certain elements in that matrix zero.
D has a size of 4000x1x10 and it represents the index of those elements which should be zero.
I am trying with this code but the problem is it only gives correct results for the 1st layer in cost1 matrix and for the remaining nine layers it doesn't make that element zero .What is wrong with my code.Kindly point out my mistake.
for yy=1:10
cost1(:,:,yy)=Costyearlydata(:,:,yy);
cost1(D)=0;
end
Your assistance is much appreciated.I am not so much familiar to dealing with 3D matrix and I am quite new to MATLAB:(
3 个评论
Walter Roberson
2020-5-22
D has a size of 4000x1x10 and it represents the index of those elements which should be zero.
The index relative to what? Relative to the 24 x 365 plane? The linear index in the 24 x 365 x 10 array?
Rabia Zulfiqar
2020-5-22
Rabia Zulfiqar
2020-5-22
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!