How to get string field from struct with each element separated
Mostrar comentarios más antiguos
>> x.name
ans =
'1.33'
ans =
'1.34'
ans =
'1.35'
>> y = [x.name]
y =
'1.331.341.35'
I want to get it like that
y = ['1.33' '1.34' '1.35']
as a matrix with three string elements
2 comentarios
And if a string vector is a true requirement, the conversion is easy:
x = struct('name',{'1.33','1.34','1.35'}) % reconstruct the data from OP
y = {x.name}
z = string(y)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Event Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!