How to crop the initial values and the last values of a column

14 visualizaciones (últimos 30 días)
Sarah DS
Sarah DS el 28 de Abr. de 2022
Editada: dpb el 29 de Abr. de 2022
Hello Matlab community, I am fairly new to Matlab and to be honest haven't used it in a while. My question is quite simple, I have a column from which I want to crop the first and the last 100 values, since they represent noise from the accelerometer.
colx = readtable(table,'Range','B100:B(end-100');
I have seen matlab has this new range function, which I am trying to use.
Thank you for your help

Respuesta aceptada

dpb
dpb el 28 de Abr. de 2022
The 'Range' named input parameter to readtable refers to the range of an input Excel spreadsheet and is not dynamic in its definition--the end keyword is only valid inside an array/variable reference, one of which you do not yet have at this point.
Simply read the full dataset into the table (or a variable if it is only a single sensor acceleration data, the table may be overkill) and then save the sections you want with colon addressing.
This also has the advantage you could get somewhat more creative and select the start/end points from the characteristics of the signal itself, not just a hardcoded fixed number of elements.
data=readtable('yourinputfile');
NtoKill=100; % the magic number
data=data(NtoKill+1:end-NtoKill,:); % keep those in between the magic number at first, end
  2 comentarios
Sarah DS
Sarah DS el 28 de Abr. de 2022
Editada: Sarah DS el 28 de Abr. de 2022
table = readtable(fileName,'Format','auto')
colx = table(101:end-100,:);
%coly = readtable(table,'Range' )
Sir, how would I specified the column here? Becase I have X, Y and Z which I have to separate for feature extraction.
dpb
dpb el 28 de Abr. de 2022
Editada: dpb el 29 de Abr. de 2022
You can't remove rows from one variable (column) in a table; it's a rectangular structure; you keep/delete all columns by rows of the table or none.
As for referencing the data in a table, you use the "dot" notation with the defined variable names; presuming something creative like X it's simply
data.X
And, use the table reference throughout, do NOT create additional variables that are simply needless copies of the same data. The latter is a very common habit/practice of the inexperienced in thinking they have to have another variable.
See (and read) the documentation on the table class; there's a full page on addressing modes to do anything you wish/desire effectively. <Access data in table>

Iniciar sesión para comentar.

Más respuestas (1)

Matt J
Matt J el 28 de Abr. de 2022
colx=colx(101:end-100,:)

Categorías

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

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by