필터 지우기
필터 지우기

User input in a struct

조회 수: 5 (최근 30일)
Etienne
Etienne 2024년 2월 16일
이동: Dyuman Joshi 2024년 2월 19일
Hello want to implment an Input request befor the following struct so that i will not have to manualy change the maschineType in the struct
motor.winding = struct(...
'windingType', 'distributed' ,... % 'concetrated' , 'distrubuted'
'machineType', 'PMSM',... %'IDM' , PMSM'
'PolePair', 4 ,...
'Number of slots', 60 , ...
'fieldModel', '2D' );
The solution could look like that:
MotorType = input('Enter IDM for induction motor and PMSM for pemanent magnet synchronous motor: ', 's')
motor.winding = struct(...
'windingType', 'distributed' ,... % 'concetrated' , 'distrubuted'
'machineType', 'MotorType',... %'IDM' , PMSM'
'PolePair', 4 ,...
'Number of slots', 60 , ...
'fieldModel', '2D' );
but i have some mistake. How can i do that properly ?
thank you
  댓글 수: 3
Etienne
Etienne 2024년 2월 16일
이동: Dyuman Joshi 2024년 2월 17일
Thank you :)
Walter Roberson
Walter Roberson 2024년 2월 16일
See also menu

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

채택된 답변

Aquatris
Aquatris 2024년 2월 16일
편집: Aquatris 2024년 2월 16일
You cannot have space in structure field name. And also as @Dyuman Joshi mentioned you should not use quotes when you assign it.
So instead try this:
MotorType = 'xxx'; % replace this with the input command, I use it to demonstrate here
motor.winding = struct(...
'windingType', 'distributed' ,... % 'concetrated' , 'distrubuted'
'machineType', MotorType,... %'IDM' , PMSM'
'PolePair', 4 ,...
'Numberofslots', 60 , ...
'fieldModel', '2D' );
motor.winding
ans = struct with fields:
windingType: 'distributed' machineType: 'xxx' PolePair: 4 Numberofslots: 60 fieldModel: '2D'
Here is the error
MotorType = 'xxx';
motor.winding = struct(...
'windingType', 'distributed' ,... % 'concetrated' , 'distrubuted'
'machineType', MotorType,... %'IDM' , PMSM'
'PolePair', 4 ,...
'Number of slots', 60 , ...
'fieldModel', '2D' );
Error using struct
Invalid field name "Number of slots".
  댓글 수: 1
Etienne
Etienne 2024년 2월 19일
이동: Dyuman Joshi 2024년 2월 19일
thanks a lot

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by