Search excel file for specific data and then copy adjacent columns in that range

조회 수: 3 (최근 30일)
matlabuser12
matlabuser12 2014년 5월 5일
댓글: Sara 2014년 5월 6일
I have an excel document that has Time|data1|data2|data3 (| denotes a new column not a delimiter) and I want to create a matlab script where I can input a specific time range in the proper format that matches the excel entry and then have matlab search the spreadsheet for those bounds and copy data from both the time column and data2 columns. How do i do this?

답변 (1개)

Sara
Sara 2014년 5월 6일
I would read in the xls file with "xlsread" (the whole set of data). Then search the first column of the imported data with the "find" command to extract the portion that interests you (your time range).
  댓글 수: 2
matlabuser12
matlabuser12 2014년 5월 6일
I will give that a try, my only concern is that the program will run very slowly since the excel file is huge (30k data rows) and xlsread already takes a noticeable time to read my test file with only 1k rows tops in it. That's why I was hoping only having to copy what I needed was possible.
Sara
Sara 2014년 5월 6일
Maybe you can read the file line by line? Using fopen and then fgetl, you get the current line in text format. You can then check if the current time is within your range and store only those values that meet your criteria.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by