Having trouble getting data into simulink from a simulink signal object
Show older comments
I'm quite new to simulink so I apologize if this is a silly question.
I'm trying to create a set of data in matlab, convert it into a bus, and create a simulink.signal so I can call it as a global variable with a Data store read block. I have been able to make this work with several types of imput data, but im having trouble making it work with timetables.
For a breif example of how im trying to do this and where im getting stuck:
Im starting with a struct ('dataTimeTables') that contains a seperate timetable for each column from a table ('dataRaw'), ends up being a 1x1 struct with 28 fields
%%%% making a bus
BusData = Simulink.Bus.createObject(dataTimeTables);
%%%% making that bus into a signal object
DataInSimulinkGlobal = Simulink.Signal;
DataInSimulinkGlobal.DataType = 'Bus : BusData';
DataInSimulinkGlobal.Complexity = 'real';
DataInSimulinkGlobal.Dimensions = 1;
DataInSimulinkGlobal.SampleTime = .02;
Now when i run it, it creates the bus and the signal in simulink with the correct dimentions and field names. I can use a data store read block to access the signal object and a bus selector to pull the appropriate bus with no errors, but when i try to inspect the data its all zeros.
My thought is that it's an issue with setting the Initial value of the signal, but i cant seem to figure out how to initalize it when it contains a timetable.
Ive tried alot of the obvious inital values ( 1, 0, -1, [ ], dataTimeTable.columnName.Properties.StartTime, dataTimeTable.columnName{1,1}, ...) without any luck
Wether this is acctually the issue, or if theres somthing else that im missing, im felling very stuck. Any help or direction would be hugely appreciated.
Also i understand that i could use a from workspace block, or a playback to make this work, which i will have to do if i can't get this to method to work, it will just cause some issues for me in later steps of my project so i would rather avoid it if possible.
Thanks Again,
Accepted Answer
More Answers (0)
Categories
Find more on Large-Scale Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!