MATLAB Answers


Can I save a row of data that has numeric and non-numeric elements?

Asked by Michael
on 11 May 2013

I have several data files (samples) that I need to process individually. The result is numeric values in a row. What I would like is to have the file name at the beginning of each row and be able to save the file so that I can append it after I process each sample.

Is there anyway to create a variable that can be saved to a file (that can be appended) that contains both numeric and non-numeric elements?

This is what I'm trying to end up with:

Sample_1 v1 v2 v3

Sample_2 v1 v2 v3

Sample_3 v1 v2 v3






No products are associated with this question.

2 Answers

Answer by the cyclist
on 11 May 2013

Cell arrays are designed to hold mixed-type data.

S = {'Sample_1',1, 2, 3}

See this documentation for lots more info:


Answer by Michael
on 11 May 2013

Thats worked to set up a row with the sample name at the beginning, however, I can't save it now matter what I try. I CAN copy and paste to an excel sheet but I have 4 hundred or so to so and was hoping to streamline the process as much as possible.

The other issue I'm finding is that I'm taking the sample name from the filename and so it looks like this:

S = {name_of_file, v1, v2}

and not like

S = {'sample_1', v1, v2}

I'm finding this leads to other problems.

Thanks for your help



I don't think he can delete his "answer" (which should have been a comment) if someone has responded to it.

the cyclist
on 12 May 2013

Michael, I'm pretty sure you should be able to accomplish what you want. Here is what I suggest. Your original question really did not give enough detail on what you wanted to do. (For example, you just said "save to a file", but what you really wanted was to write Excel.)

In rereading your question and then the other detail you added later, it is frankly still not clear what you are trying to do. I suggest you abandon this question and start a new one, really trying to focus on a very clear and specific outline of what you want. Remember, we don't know anything other than what you tell us.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!