How to read comma separated input data containing values & stings which also has ',' & ';' used for separation?

How to read comma separated input data containing values & stings which also has ',' & ';' used for separation?
Example:
#SATVISA,COM1_30,0,88.5;COARSESTEERING,1833,167463.000,00400000,0947,12996;TRUE,TRUE,30,16,0,0,79.0,111.5

 Accepted Answer

doc textscan % NB: 'delimiter' Name-Value Pair with example for multiple delimiter characters.

6 Comments

Thank you so much.
I got the answer in a cell format which I am unable to use as input. I got answer as C_text cell and C_text{1,1} has the array I need.
I am using d = cell2mat(c) to convert it into one array but I am getting error as 'Cannot support cell arrays containing cell arrays or objects.'
Is there any other way I can convert this output in readable format for my program?
I got it when I saved the C_text{1,1} as a separate variable.
Thank you so much.
Well, your input line as mixed text and numeric fields so it can't be anything but either a cell array or recast to a structure or somesuch.
You don't say what specific format you do need so don't know what to say for any explicit rearrangement that might be more suitable. If there's still an issue, post back the details of what your requirements are and we'll see...
When I decoded the data from input file, all output data array came in cell format. Example: {'38.95','-95.25';'38.94','-95.24';'38.93','-95.23';}
With this data I am unable to plot any graph or do any operations so I tried to convert it into normal array form by using STR2DOUBLE, str2num, cell2mat but I am not able to get it right.
Because this is in cell form I had to use 'isequal' function instead of '==' for normal operations.
I need this data in a normal matrix form in order to do the operations like plot and normal mathematical operations.
Is there any way I can do that?
Use the 'collectoutput',1 name-value pair to put the string and numeric data into separate (still cell) arrays. Again I repeat, you can not put the two types of data in the same array; just not possible.
You can then use cell2mat on the numeric array to get a regular array of numeric values; again you leave out pertinent details of what data are to go together for plotting, etc., so that's a detail to deal with.
Or, of course, to use the cell array as is, you "use the curlies" the {} brackets to dereference the content of a cell. Read the doc on cell arrays for the details there.
Again, specific examples of what you want to do help more than just generalizations.
I will try this approach. Thank you so much!

Sign in to comment.

More Answers (0)

Asked:

on 11 Mar 2015

Commented:

on 12 Mar 2015

Community Treasure Hunt

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

Start Hunting!