How can i delete certain numbers of an array

조회 수: 1 (최근 30일)
marios semer
marios semer 2020년 12월 10일
댓글: marios semer 2020년 12월 10일
Hi, i have and array with numbers [ 0 , pi ] and i want to delete all the samples from 0.4*pi to 0.5*pi to have one array with numbers between [0,0.4*pi] and [0.5*pi , 0] .
How can i do it ?
w = linspace(0 , pi , 260);

답변 (2개)

Ameer Hamza
Ameer Hamza 2020년 12월 10일
You can use logical indexing
w = linspace(0 , pi , 260);
idx = (w > 0.4*pi) & (w < 0.5*pi);
w(idx) = []

Star Strider
Star Strider 2020년 12월 10일
One approach:
w = linspace(0 , pi , 260);
we = w((w < 0.4*pi) | (w > 0.5*pi)); % ‘w’ Edited
.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by