dimanche 22 février 2015

How to use sprintf/fprintf to print a string inside a cell array in matlab?

I was wondering if it was possible to use sprintf or fprintf to print something to a cell array.


In a structure A I have



A.labels = {'A' 'B' 'C' 'D'}


and I have a string/cell array



B = {'E' 'F' 'G' 'H'}


and I want to print into a new structure C such that I want



C.labels = {'A-E', 'B-F', 'C-G', 'E-H'}


In the code below I am just trying to check how to do the first entry and then once I figure that out I can do the rest myself.



C(1).labels = fprintf('%s -%s',B{1},A(1).labels);


But this does not do the job. How can I fix this?


Aucun commentaire:

Enregistrer un commentaire