MATLAB Answers

Import Workspace Data - Lookup Table vs. From Workspace?

31 views (last 30 days)
Ethan Ott
Ethan Ott on 4 May 2011
In some models I use the from-workspace block as usual create simulink signals based on workspace data. I have also used a 1D Lookup-table block to accomplish the same thing by attaching a clock block to the table input and configuring the table with the time vector as input values and the signal data as the output values.
Is either method more efficient? What are the pro/cons for each method?
I think I started using the Lookup-tables because the workspace data (time and signal vectors) were not always oriented as a column vector as the from-workspace block requires.
-Ethan

  0 Comments

Sign in to comment.

Answers (1)

MarkB
MarkB on 5 May 2011
As a third method, I would propose using an inport, and then specifying a workspace variable using the "Import/Export" section of the Configuration Parameters to specify a MATLAB workspace variable to read as an input.
This has several advantages over the other approaches. For both of the other options, if you place the model inside of a larger model reference hierarchy, you will find yourself locked into using the same workspace variable for every instance. By using an input port, on the other hand, the data will come from whatever signal line is connected to it, making each instance more flexible.
Also, any signal-based inputs can be driven by a Signal Builder block further upstream. This provides a much easier way to coordinate changes in the signal's value with other signals if there are timing dependencies.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!