Simulink.Signal Object array creation

조회 수: 5 (최근 30일)
Sumit Kumar
Sumit Kumar 2025년 2월 10일
댓글: Sumit Kumar 2025년 2월 14일
Hello Community,
I am trying to create a script that will read signal information to Simulink data dictionary.
Can i create an array for Simulink.Signal objects.
With Regards,
Sumit

답변 (1개)

Manikanta Aditya
Manikanta Aditya 2025년 2월 11일
Yes, you can create an array of Simulink.Signal objects in MATLAB. Here's a simple example to help you get started:
  1. Define the Array: Create an array of Simulink.Signal objects in the MATLAB workspace.
  2. Initialize Each Element: Initialize each element of the array with the desired properties.
% Define the number of signals
numSignals = 5;
% Initialize an array of Simulink.Signal objects
signalArray = repmat(Simulink.Signal, 1, numSignals);
% Set properties for each signal
for i = 1:numSignals
signalArray(i).Dimensions = 1;
signalArray(i).DataType = 'double';
signalArray(i).Complexity = 'real';
signalArray(i).RTWInfo.StorageClass = 'ExportedGlobal';
end
% Assign names to each signal
for i = 1:numSignals
assignin('base', ['Signal_' num2str(i)], signalArray(i));
end
% Display the signal array
disp(signalArray);
1x5 Signal array with properties: Dimensions DimensionsMode Complexity SampleTime InitialValue CoderInfo Description DataType Min Max Unit
Refer to the following documenations to know more about:
I hope this helps.
  댓글 수: 1
Sumit Kumar
Sumit Kumar 2025년 2월 14일
Thank You @Manikanta Aditya For the reply i will check and confirm.

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

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by