Delete rows from an array
古いコメントを表示
Good afternoon
I have a long array of numbers, CEC (52560x1) and I would like to delete the rows in the following way:
r = 1:1:8760
t = 0:1:8759
CEC((2+6*t):(6*r))
I tried to set it into a loop by:
for r = 1:1:8760
for t = 0:1:8759
CEC((2+6*t):(6*r)) = [];
end
end
But it is not working for me. Any ideas?
Thank you!
3 件のコメント
SHIVAM KUMAR
2020 年 12 月 15 日
Couldn't get how you want to delete in a 1 D array like that .
CEC((2+6*t):(6*r)) = [];
This shall change all locations from 2+6*t to 6* r to empty.
and doing in loop means entire array will become empty except index [1,2]
Ricardo López
2020 年 12 月 15 日
Image Analyst
2020 年 12 月 15 日
Please give some actual numbers. For example, what indexes represent the first set of rows to delete, and the second set of rows to delete?
採用された回答
その他の回答 (1 件)
SHIVAM KUMAR
2020 年 12 月 15 日
編集済み: SHIVAM KUMAR
2020 年 12 月 15 日
Your code will work like this if used on 1 D array .
CEC((2+6):end) = [0];
If you are using that your array shall be 52560X52560.
then you can use
for r = 1:1:8760
for t = 0:1:8759
CEC((2+6*t),(6*r)) = [0]; %Use a comma
end
end
1 件のコメント
SHIVAM KUMAR
2020 年 12 月 15 日
ie. only have values for index 1 to 8 and all other indexes will be 0.
カテゴリ
ヘルプ センター および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!