Need some help learning Simulink

2 views (last 30 days)
DJ V
DJ V on 24 Sep 2024
Moved: Sam Chak on 26 Sep 2024
I'm having some trouble with Simulink. I need to be able to frame the input to an integration routine in terms of the time variable, t. I do this with a Matlab function, but "t" isn't the value of the variable that is produced. I don't know how to use "t" in this manner. (I'm defining a function for Fx as t^2, which winds up as u^2.)
I also need to model the output both as a plot file and as a data printout. I don't seem to be able to produce this.
Does anyone have the Matlab background necessary to understand this Simulink problem? Thank you.
Sincerely,
Del Ventruella

Answers (1)

Raghava S N
Raghava S N on 25 Sep 2024
Hey,
The “Clock” block in Simulink outputs the current simulation time at each simulation step. This block is useful for other blocks that need the simulation time. The output of the “Clock” block should be connected to the input of the MATLAB function block. As a result, the output of the MATLAB Function block will be “t^2”. For more information about the “Clock” block in Simulink, refer to the following link - https://www.mathworks.com/help/simulink/slref/clock.html.
The Simulink Data Inspector can be used to create plots and view the outputs of the simulation. Right click on the signals that need to be plotted and select “Log Selected Signals”. This enables signal logging with the Simulink Data Inspector. After the simulation is completed, clicking on the blue icon on top of the logged signals launches the Simulink Data Inspector. More information about creating plots using Simulink Data Inspector can be found here - https://www.mathworks.com/help/simulink/ug/create-plots-with-the-simulation-data-inspector.html.
To save the output as raw data, the “To File” block in Simulink can be used. The data can be saved to a “.mat” file as a Timeseries object or as a MATLAB Array, by setting the “SaveFormat” parameter. Refer to this link for more information about saving simulation data - https://www.mathworks.com/help/simulink/slref/tofile.html.
I have attached the Simulink model with the modifications listed above. Hope it helps!
  3 Comments
Raghava S N
Raghava S N on 26 Sep 2024
Sure, I have attached the model compatible with MATLAB R2019b.
With regards to working with MATLAB and Simulink simultaneously, I would suggest you to take a look at these self-paced online courses that give you a basic overview of working with MATLAB and Simulink -
Feel free to ask any more questions!
DJ V
DJ V on 26 Sep 2024
Moved: Sam Chak on 26 Sep 2024
I'm not getting error messages relative to a new integration problem that I've mapped into Simulink. Its telling me the following when I run it:
Simulation 8 3
10:54 AM Elapsed: 2 sec
Output port 1 of 'SimIntegrator/Cpsi2' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/P' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/Q1' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/R2' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/Spsi2' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/U' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/V1' is not connected.
Component:Simulink | Category:Block warning
Output port 1 of 'SimIntegrator/W2' is not connected.
Component:Simulink | Category:Block warning
Error evaluating 'StartFcn' callback of MultiPlot Graph block (mask) 'SimIntegrator/Output Graph3'.
Callback string is 'sfun_multiplot([],[],[],'Start')'
Caused by:
There should be a single port of width NU.
Component:Simulink | Category:Block error
Error evaluating 'StartFcn' callback of MultiPlot Graph block (mask) 'SimIntegrator/Output Graph4'.
Callback string is 'sfun_multiplot([],[],[],'Start')'
Caused by:
There should be a single port of width NU.
Component:Simulink | Category:Block error
Error evaluating 'StartFcn' callback of MultiPlot Graph block (mask) 'SimIntegrator/Output Graph5'.
Callback string is 'sfun_multiplot([],[],[],'Start')'
Caused by:
There should be a single port of width NU.
Component:Simulink | Category:Block error
I understand the reason for the warnings, but I don't grasp the basis for the errors. Does anyone else? ("There should be a single port of width NU?") Please respond if you do. Thank you.
I've attached the file.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!