Combining numbers and string in a vector then output to an excel sheet

5 views (last 30 days)
Hi, im running a function which adds a series of metrics and classifies what im running based on these metrics. The classification is a string and the metrics are numbers. The metrics are currently in a vector and the classification is in a variable. I can get them each to output separately if i change the function to output each individually, but cant get them both to output, ive tried adding the string variable to the end of the vector but it doesn't work.
After i have the metrics and the classification as one output i want it to add to a master excel document, where each time i run the function, the knew metrics and classification adds under the other data in the excel document in the next available row, is this possible?
Thanks!

Answers (1)

the cyclist
the cyclist on 19 Sep 2014
One way to mix data types in one variable is to use a cell array.
There are many ways to then export that cell array. I generally use the user-contributed cellwrite function from the File Exchange.
  3 Comments
Guillaume
Guillaume on 19 Sep 2014
I would suggest you accept the cyclist answer and starts a new question just on this topic.
the cyclist
the cyclist on 19 Sep 2014
My usual approach is to do the formatting and arranging on the MATLAB side, and then just write what I want to csv. (MATLAB does not play nicely with Excel files on a Mac, due to lack of COM server.)
Other folks may be able to help more. You might want to open up a new question with a bit more detail on exactly what you are trying to do, maybe with a small example of the data you want to write.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!