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)
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

Accepted Answer

Cam Salzberger
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
  1 Comment
Christian-Nils Boda
Christian-Nils Boda on 1 Sep 2015
Hello Cam,
Thank you for your answer and the explanation. I am using R2014b and it seems that "From Workspace" block allows me to import data with NaNs. But I guess I better update my code accordingly to your example (or the other MATLAB Answers post).
Thank you again,
/CN

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!