フィルターのクリア

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 Center および File ExchangeMotor Drives についてさらに検索

製品


リリース

R2007b

Community Treasure Hunt

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

Start Hunting!

Translated by