Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading strings into Matlab from excel?

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?

like image 441
Ben Fossen Avatar asked Jun 23 '10 18:06

Ben Fossen


People also ask

How read data from Excel to MATLAB?

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.

How do I read a string in Excel?

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.

How save data from Excel to MATLAB?

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 .

Can you use MATLAB with Excel?

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.


2 Answers

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')
like image 106
JudoWill Avatar answered Oct 18 '22 01:10

JudoWill


I need to use this [num, txt, raw] = xlsread('data.xlsx',1, 'D2:D4')

the txt will import stings into Matlab.

like image 38
Ben Fossen Avatar answered Oct 18 '22 00:10

Ben Fossen