MATLAB: Is it possible to import data vectors containing NaN values using ‘From Workspace’ block in Simulink 7.4 (R2009b)

importnansimulink

While importing data vectors containing NaN values using 'From Workspace' block in Simulink 7.4, I receive the following error:
Invalid matrix-format variable specified as workspace input in 'ModelName/From Workspace'.

Best Answer

In order to import data vectors containing NaN values using the 'From Workspace' block, you need to use 'Simulink.Timeseries' objects.
The attached data file 'Data.mat' contains a Simulink.Timeseries object 'Mydata' which has some of its data values defined to be NaN. The associated model "test_WS" depicts how the 'From Workspace' block with its 'Data' field set to 'Mydata' can import those NaN values and still be able to execute without any errors.