필터 지우기
필터 지우기

How do I extract the first 25% of data? Matlab help

조회 수: 8 (최근 30일)
George  Zimbodia
George Zimbodia 2014년 9월 7일
답변: Mahesh 2014년 9월 7일
I was asked to extract the first 25% of the data that I was given. For instance the dimensions of w is equal to 1 by 900. Also, I am not to hard code the range for extraction but instead base the range of the length of the data. (so it should work whether w is 1by900 or 1by50)..

답변 (1개)

Mahesh
Mahesh 2014년 9월 7일
I hope you are trying to get the 25 percent of data out of number of data you have. If you have n = 900 datapoint, the following codes might help say you have data is the vector
ndata = size(data, 2) % number of data points
p = 25; percent of data
%compute number of data points you wants
newpoints = floor(ndata*p/100);
%turn row vecror to column vector so that you wont get confused
data = data(:);
newdata = data(1:newpoints); % this will be your new extracted data points
This is the case of one dimensional vector. I hope you can recode for multidimensional in similar way. Good luck Mahesh

카테고리

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