Filter löschen
Filter löschen

Cell array to text form

1 Ansicht (letzte 30 Tage)
nayan
nayan am 29 Mär. 2021
Bearbeitet: Stephen23 am 29 Mär. 2021
New to Matlab - guess this will be quite easy for anyone using matlab:
If you have the following in a cell array:
L1125
Y8898
P41
5666
But you want it written in the following format:
'L1125','Y8898','P41','5666'
So basically adding an comma and apostrophe as shown above

Antworten (1)

Stephen23
Stephen23 am 29 Mär. 2021
Bearbeitet: Stephen23 am 29 Mär. 2021
I suspect that you are confusing how data are stored with how they are defined and displayed, but anyway:
C = {'L1125';'Y8898';'P41';'5666'}
C = 4×1 cell array
{'L1125'} {'Y8898'} {'P41' } {'5666' }
S = sprintf(',''%s''',C{:});
S = S(2:end)
S = ''L1125','Y8898','P41','5666''
Note that the leading and trailing single quotes are just an artifact of displaying, they are not actually in the character array (you can easily check this yourself by looking at the character codes).

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by