Why is numeric data written as character data when using the MLPutMatrix command via Excel Link?
1 view (last 30 days)
Show older comments
To replicate this problem, create an Excel sheet with the following data:
A B
1 c 12345678901234567890
2
Use MLPutMatrix command to put the data in cells A1:B1 into MATLAB as follows:
MLPutMatrix("a", "A1:B1")
The resulting variable a in MATLAB has the following format:
a =
'c' [1x20 char]
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
This is an expected behavior. If the data being passed has any non-numeric element in it (except +, -, e or E), the entire data will be converted to a cell array of characters within MATLAB.
Once the data is passed to MATLAB, use the STR2NUM function in MATLAB to convert the required data to numeric format or to make sure all data passed via MLPutMatrix is numeric.
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!