how to delete data with special value in an array?

조회 수: 2 (최근 30일)
Haotian Wang
Haotian Wang 2021년 5월 13일
편집: per isakson 2021년 5월 13일
there is an array with 800 values, and the mean of these can be calculated.
I would like to delete the value over or less than 0.5 than the mean of the value. how can I do that?

채택된 답변

per isakson
per isakson 2021년 5월 13일
편집: per isakson 2021년 5월 13일
"to delete the value" Do you mean remove? If so, try this script which uses logical indexing
%%
vec = 1+2*randn( 1, 800 ); % sample data
avg = mean( vec );
vec( vec<avg-0.5 | avg+0.5<vec ) = [];
size(vec)
ans = 1×2
1 152

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by