I would like to read strings into Matlab from an excel file
ID = xlsread('data.xlsx',1, 'D2:D4')
the cells in range D2:D4 have strings in them. When I try to import the strings into Matlab all I get is an empty list? what can I do to fix this?
Import Spreadsheet Data Using the Import Tool xls as a table in MATLAB. Open the file using the Import Tool and select options such as the range of data and the output type. Then, click the Import Selection button to import the data into the MATLAB workspace.
Depending on where you want to start extraction, use one of these formulas: LEFT function - to extract a substring from the left. RIGHT function - to extract text from the right. MID function - to extract a substring from the middle of a text string, starting at the point you specify.
To export a table in the workspace to a Microsoft® Excel® spreadsheet file, use the writetable function. You can export data from the workspace to any worksheet in the file, and to any location within that worksheet. By default, writetable writes your table data to the first worksheet in the file, starting at cell A1 .
After you have data in a Microsoft Excel spreadsheet, you can execute MATLAB functions using various methods. For example, you can use the Microsoft Excel ribbon, context menu, worksheet cells, or VBA macros. To find MATLAB functions in a visual way, use the MATLAB Function Wizard.
If you're in Matlab 2010 you can also do something like this to avoid having extra values in your workspace.
[~, ~, raw] = xlsread('data.xlsx',1, 'D2:D4')
I need to use this [num, txt, raw] = xlsread('data.xlsx',1, 'D2:D4')
the txt will import stings into Matlab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With