Sample Time in From Workspace Block

5 views (last 30 days)
Carlos
Carlos on 7 Mar 2016
Answered: Sameer on 6 May 2025
Hello, I have some model that uses temperature data collected for one year. If I use as an input a sinusoidal signal, my output follows the correct model, but, if I put my data signal it does not follow the model. I think that the problem is that my input signal (data and time) has a total length of 9000, but if I try to plot it, it is using just 300 aprox. Is there any way to use the sample time exact that is in my data?
Thank you.

Answers (1)

Sameer
Sameer on 6 May 2025
To make Simulink use the exact sample times from your data with the "From Workspace" block:
1. Format your data as a two-column matrix:The first column is time, the second is your signal.
codedata = [time_vector, signal_vector];
2. Set the From Workspace block’s "Sample time" to -1:This tells Simulink to use the time values from your data instead of a fixed sample time.
3. Set the simulation Start and Stop times to match the range of your time data (e.g., Start time = time_vector(1), Stop time = time_vector(end)).
This way, Simulink will use all your data points at the exact times you have in your file.
Hope this helps!

Products

Community Treasure Hunt

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

Start Hunting!