User input in a struct
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
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
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' );
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!