How do I extract the first 25% of data? Matlab help
조회 수: 6 (최근 30일)
이전 댓글 표시
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)..
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!