필터 지우기
필터 지우기

How to read a specific line containing a value?

조회 수: 7 (최근 30일)
jacques baptiste
jacques baptiste 2018년 3월 20일
댓글: jacques baptiste 2018년 3월 22일
Hello,
I would like to read the excel line where for example the ID "445678" is written, in order to display the data into edit text box (only 2 columns actually). I did try with find but my excel is composed by numbers and letter so this is not working.
A little help would be appreciated, even just a way of doing it. Thanks for reading
Best regards, Baptiste
  댓글 수: 4
Guillaume
Guillaume 2018년 3월 20일
Any reason you're not using readtable instead of xlsread? It would make your life easier.
I don't understand how the screenshot relates to your code where you appear to be searching for the values 101 to 109 which do not appear in that screenshot. In any case, a loop is not required. ismember with the 'rows' option is probably what you need.
I also don't understand how your code relates to your question of finding ID 445678.
Finally, rather than a screenshot (wich we can't use to test code), a demo excel file would be more useful.
jacques baptiste
jacques baptiste 2018년 3월 20일
No reason, I used it because I knew this function. is there any advantage to use readtable? Yeah it was not a good example sorry, my excel file is a file to test with random value/name (see attachment).
I want to be able to get the project name (column 1) and the ModuleID (column 3) from the channel number (101,102.. column 4).
Then i want to display name and ID in 2 edit text boxes in a GUI made with GUIDE. Sorry if it is not clear.

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

채택된 답변

Guillaume
Guillaume 2018년 3월 20일
"is there any advantage to use readtable?"
It's simply a more powerful version of xlsread. It figures out the format of the excel file (also works with text file), use that to label the columns and outputs a table. Tables are easier to work with than cell arrays.
If it weren't for that single 'k' on row 15, all you had to do to read the file was:
t = readtable('PVdata.xlsx')
With that 'k', it needs a hint:
t = readtable('PCdata.xlsx', 'Range', '1:10')
"I want to be able to get the project name (column 1) and the ModuleID (column 3) from the channel number (101,102.. column 4)"
I'm not entirely clear what you want. To get the project name and module ID for e.g. channel 103:
t.ProjectName(t.Channel == 103)
t.ModuleId(t.channel == 103)
See how easy it is to work with tables.
  댓글 수: 1
jacques baptiste
jacques baptiste 2018년 3월 22일
Thanks a lot for the explanations, it's working perfectly with readtable and the structure format.

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

추가 답변 (0개)

카테고리

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