Borrar filtros
Borrar filtros

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

8 visualizaciones (últimos 30 días)
George  Zimbodia
George Zimbodia el 7 de Sept. de 2014
Respondida: Mahesh el 7 de Sept. de 2014
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)..

Respuestas (1)

Mahesh
Mahesh el 7 de Sept. de 2014
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

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by