问题
I need to do a very basic operation of adding two numbers in Simulink. The values are stored as variables in the workspace.
The 'From Workspace' block seems to take either Timeseries or structures as input. I am not sure how to convert the data to do this basic operation.
回答1:
You can use a Constant blocks and use the name of the variable as the value.
回答2:
- If your "numbers" are parameters - that is they do not vary with time - use Constant blocks.
- If they are variables or signals- i.e. they are time-dependent - then use the From Workspace blocks, and package the data as described in the documentation (array, timeseries, etc...) so that you have the data + the corresponding time values.
You have to remember that Simulink is for modelling dynamic systems that vary with time, so everything is assumed to be time-dependent. Having said that, you can parameterize any block in Simulink using data (read parameters) from the base workspace, it's picked up automatically by Simulink.
For simple operations on data that is not time-dependent (parameters), you are better off using MATLAB than Simulink.
来源:https://stackoverflow.com/questions/26742660/how-to-input-double-values-in-simulink-from-workspace