Simulink: Why can I load data from workspace containing NaNs and not when I load data from a MAT-file?
6 views (last 30 days)
Show older comments
Christian-Nils Boda
on 27 Aug 2015
Commented: Christian-Nils Boda
on 1 Sep 2015
Hello,
I am curious to know why it is impossible to load data containing NaNs in Simulink from a MAT-file while it is possible to do so when using the data from the workspace. Any insights would be appreciated.
Thanks
0 Comments
Accepted Answer
Cam Salzberger
on 31 Aug 2015
Hello Christian-Nils,
I believe that, at least in R2015a, you cannot import data in matrix format that contains NaN or Inf with either a "From Workspace" or "From File" block. Because Simulink is so time-dependent, it is my understanding that this restriction is to prevent the possibility of NaN or Inf time values.
However, if you construct a Simulink Timeseries object and either have it in the workspace or saved to a file, you can include NaN or Inf data values. Here's a quick example:
A = Simulink.Timeseries;
set(A,'Time',(0:3).');
set(A,'Data' , [1 1 NaN 1].');
You can also check out this MATLAB Answers post, which contains data with NaNs and a model that can read it.
I hope this explanation helps!
-Cam
More Answers (0)
See Also
Categories
Find more on Sources in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!