필터 지우기
필터 지우기

How to create a struct?

조회 수: 1 (최근 30일)
Josy M
Josy M 2020년 7월 17일
댓글: Walter Roberson 2020년 7월 18일
Hello,
How can i split my "scenarioServiceCopy" 1*54 struct in two parts? For example:
  • 1-30 fields -> part 1
  • 31-54 fields in part 2
In this way i store the data in my struct:
parameter.scenarioServiceCopy(count).(namess{7})=char(array_(1,7))
I do this with a for loop. It works but everything is in one "matrix/table/struct".
I want to have something like this:
  • part 1 first 30 fields: parameter.scenarioServiceCopy(1)
  • part 2 the last 24 fields: parameter.scenarioServiceCopy(2)
But does something like this works
Thanks
  댓글 수: 3
Josy M
Josy M 2020년 7월 17일
difficult for me :D
is it possible to make a 2*85 struct with 16 fields? I read the manual but its really hard to understand for a hobby programmer :/
Walter Roberson
Walter Roberson 2020년 7월 18일
How should 54 input fields map on to 2*85 with 16 fields?
v = fieldnames(scenarioServiceCopy);
tc = struct2cell(scenarioServiceCopy);
p1 = cell2struct(tc(1:30,:,:),v(1:30));
p2 = cell2struct(tc(31:end,:,:), v(31:end));
parameter.scenarioServiceCopy1 = p1;
parameter.scenarioServiceCopy2 = p2;

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

답변 (1개)

Bhupendra Prajapati
Bhupendra Prajapati 2020년 7월 17일
편집: madhan ravi 2020년 7월 17일
parameter = struct(scenarioServiceCopy(1),scenarioServiceCopy(2));
Just follow the exmaples given at the link below ->
  댓글 수: 1
Josy M
Josy M 2020년 7월 17일
this programm Code does not work so far

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

카테고리

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