Azzera filtri
Azzera filtri

Struct information string extraction

2 visualizzazioni (ultimi 30 giorni)
Conner Carriere
Conner Carriere il 26 Ott 2022
Modificato: Jan il 26 Ott 2022
I have a Struct that I want to get word info out of.
I know if I want to pull out the "id" numbers, I do
vals = [data.categories.id]
%that outputs
vals =
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
%but if I want .name
vals = [data.categories.name]
vals =
'Damage-DetectionFront-Windscreen-DamageHeadlight-DamageMajor-Rear-Bumper-DentRear-windscreen-DamageRunningBoard-DentSidemirror-DamageSignlight-DamageTaillight-Damagebonnet-dentdoorouter-dentfender-dentfront-bumper-dentmedium-Bodypanel-Dentpillar-dentquaterpanel-dentrear-bumper-dentroof-dent'
All of the string is pushed together. How can I extract that and get a matrix so I can match it up with the .id vals
  2 Commenti
Chunru
Chunru il 26 Ott 2022
attach "data" as a mat-file
Mathieu NOE
Mathieu NOE il 26 Ott 2022
hello
you can use split to get individual strings
vals = split(vals,'-');

Accedi per commentare.

Risposta accettata

Jan
Jan il 26 Ott 2022
Modificato: Jan il 26 Ott 2022
[] concatenates the CHAR vectors to one big CHAR vector and the result is expected. If you want a cell string, use curly braces:
vals = {data.categories.name};

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by