How to create bus from timeseries object including enumerated class?

7 ビュー (過去 30 日間)
Shouqin
Shouqin 2016 年 3 月 3 日
編集済み: per isakson 2016 年 4 月 17 日
1) I define an enumerated class BHA **
classdef BHA
enumeration
Stationary, Run
end
end
**** (2) Then I generate a timeseries ****
clear all; close all;
for row = 1:12
a(:,:,row) = [1;2;3];
b(:,:,row) = [1;2]*9.8;
c(:,:,row) = BHA.Stationary;
end
HallwaySensonor.a = timeseries(a);
HallwaySensonor.b = timeseries(b);
HallwaySensonor.c = timeseries(c);
save('HallwaySensonor.mat','HallwaySensonor','-v7.3');
*** (3) Now as I try to create the bus, I got the trouble ***
load('HallwaySensonor.mat');
busInfo = Simulink.Bus.createObject(HallwaySensonor);
*** It shows Error using Simulink.Bus.createObject>createBus (line 324) Simulink.Bus.createObject reported the following error when processing the field 'c' in the input structure:
'Invalid value specified for parameter
object. Value must be a numeric array,
fi object, an enumerated value, or a
scalar structure whose fields contain
valid values.'
&nbsp
Error in
Simulink.Bus.createObject>createObjectFromVarStruct
(line 242)
name = createBus(sp, '', name, 0,
scope);
Error in Simulink.Bus.createObject (line
105)
busInfo =
createObjectFromVarStruct(sp,
busName, fileName, format, scope);
Error in BusCreation (line 13)
busInfo =
Simulink.Bus.createObject(HallwaySensonor);

採用された回答

Venkatachala Sarma
Venkatachala Sarma 2016 年 3 月 10 日
編集済み: per isakson 2016 年 4 月 17 日
Try subclassing BHA from Simulink.IntEnumType.
classdef BHA < Simulink.IntEnumType
enumeration
Stationary(0),
Run(1)
end

その他の回答 (1 件)

Shouqin
Shouqin 2016 年 3 月 10 日
Thanks!

カテゴリ

Help Center および File ExchangeCreate Report Programs Using the Report API についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by