I want to remove the first couple lines in an excel file as it is irrelevant information. I could do this in excel however, it would be much easier in Matlab as I have a lot of data files to import into Matlab.
Here is my code:
clear, clc, close all
AE_data = readmatrix('file')
AE_data(1:2,:) = [];
For some reason when I run this code it does not delete the rows. When i evaluate the specific line of code it deletes the rows. What am I doing wrong? I cannot figure out why Matlab will not delete these rows.
Thanks.

댓글 수: 3

Jan
Jan 2023년 2월 20일
"when I run this code it does not delete the rows. When i evaluate the specific line of code it deletes the rows." - Please explain, what this means. I sounds like a contradiction.
The code does delete the 1st and 2nd row. So I assume that your observation is not correct.
Steven Lord
Steven Lord 2023년 2월 20일
The code you've written does delete the first two rows in the copy of the data you loaded into MATLAB. It does not delete the first two rows in the file itself. Is the latter what you're trying to do?
Reed Smith
Reed Smith 2023년 2월 20일
I have no idea why. It simply does not delete the rows no matter what. I am going to delete this question as I think this is an error with my Matlab and not the code.

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

 채택된 답변

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 20일
Here is one example that shows it works:
D = readmatrix('Data2.xlsx', 'Sheet', 1) % All imported
D = 13×2
1 5 2 7 3 9 4 11 5 13 6 15 7 17 8 19 9 21 10 23
D(1:2,:)=[] % Two rows are removed
D = 11×2
3 9 4 11 5 13 6 15 7 17 8 19 9 21 10 23 11 25 12 27

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2023년 2월 20일

댓글:

2023년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by