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!