필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Sarah DS
Sarah DS 2022년 4월 28일
편집: dpb 2022년 4월 29일
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

채택된 답변

dpb
dpb 2022년 4월 28일
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
Sarah DS
Sarah DS 2022년 4월 28일
편집: Sarah DS 2022년 4월 28일
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 2022년 4월 28일
편집: dpb 2022년 4월 29일
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>

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2022년 4월 28일
colx=colx(101:end-100,:)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by