Struct information string extraction

조회 수: 3 (최근 30일)
Conner Carriere
Conner Carriere 2022년 10월 26일
편집: Jan 2022년 10월 26일
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
Chunru
Chunru 2022년 10월 26일
attach "data" as a mat-file
Mathieu NOE
Mathieu NOE 2022년 10월 26일
hello
you can use split to get individual strings
vals = split(vals,'-');

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2022년 10월 26일
편집: Jan 2022년 10월 26일
[] 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};

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by