How to read a specific line containing a value?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jacques baptiste
el 20 de Mzo. de 2018
Comentada: jacques baptiste
el 22 de Mzo. de 2018
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 comentarios
Guillaume
el 20 de Mzo. de 2018
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.
Respuesta aceptada
Guillaume
el 20 de Mzo. de 2018
"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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!