Define Array data type

조회 수: 35 (최근 30일)
Iban
Iban 2011년 5월 19일
Hello,
I have a Simulink model, where I need to define some custom data types. For that, in a .m file I a writting something like this:
tSpeed = Simulink.AliasType;
tSpeed.BaseType = 'single';
tSpeed.Description = '[Kmh]';
tDistance= Simulink.AliasType;
tDistance.BaseType = 'single';
tDistance.Description = '[meters]';
The idea is to set the datatype of the input/output ports of the simulink model to 'tSpeed' or 'tDistance', in spite of setting them to 'single' datatype.
Now, my problem is the following: I want to define another datatype which is not just a 'single', but is an array of 6 single numbers.
Does anybody know how can I do that?

채택된 답변

MarkB
MarkB 2011년 5월 23일
Fangjun is correct, the data type is independent of/orthogonal to the dimensions. You can also set the dimensions on most blocks by opening their parameter dialogs and assigning it there as well.
It is also worth noting that you can still "parameterize" this dimension, meaning that it can be a MATLAB workspace variable, as opposed to a hard-coded number. From there, you could use the same variable in multiple dialogs, edit the workspace variable, and change the dimensions of a bunch of blocks' outputs simultaneously.

추가 답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 5월 19일
As it indicates, Simulink.AliasType allows you to designate MATLAB variables as aliases for signal and parameter data types. If you want to specify your signal as a vector signal, you can specify the Dimensions of the signal.
a=Simulink.Signal;
a.Dimensions=[1 6]
  댓글 수: 3
Fangjun Jiang
Fangjun Jiang 2011년 5월 19일
My understanding is the Simulink.AliasType is for custimizing data types only, you know, single, interger, unsigned interger, etc.
What did you do to specify the data type of your Inport?
Iban
Iban 2011년 5월 19일
Ok, it doesn´t matter, I will do it as you suggested.
Ah, and forget the error, it was just an spelling mistake.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by