How to delete every alternate rows?

27 次查看(过去 30 天)
Hi,
In the attached array sz, I need to delete every alternate rows starting from first row, (e.g. 1, 3, 5, 7 etc). Could someone help?
  1 个评论
Dyuman Joshi
Dyuman Joshi 2024-4-5
You have been active here since 2020, I am really surprised that you had to ask for this.

请先登录,再进行评论。

采纳的回答

Ayush Anand
Ayush Anand 2024-4-5
Hi,
You can do
sz_new = sz(2:2:end, :);
This will do the job.
  4 个评论
Aquatris
Aquatris 2024-4-5
Alternatively you can also delete them from your current variable:
x = 1:10;
x % show x
x = 1x10
1 2 3 4 5 6 7 8 9 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
x(1:2:end) = [];% delete odd idx values
x % show x after removing odd values
x = 1x5
2 4 6 8 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by