How to manage global data between Matlab workspace, Simulink and then into Simscape physical signals and custom component
6 views (last 30 days)
Show older comments
I am planning on creating custom components inside of Simscape (Fluids). I have already been able to share Matlab variables/data to simulink although it really feels more like a workaround than a system (Settings timeseries which have to match the dimension with signal.values etc).
Now I need data that I import from an csv file (located in my Matlab workspace as it is imported before running the Simulink system), specifically in a Simscape component. The problem is that I am able to get the data as a signal from the matlab workspace to simulink. But then I need to get the simulink signal into a Simscape (custom) component.
My first idea was just use a Simulink-PS converter and add a input to the custom simscape component, but of course that does not support data higher dimensions than 0D (1x1 as a time series).
Then my second idea was to add a node that already is of type simulink signal. However as far as I can see in the documentation it is not possible to directly communicate between a simscape component and simulink signal (probably result of the physical values with units attached).
(For sanity I also tried directly using any of the functions, like readmatrix or using global but as I expected from ealier experience this is not allowed due to simulatoin slow down etc)
That now brings me to where I am. Not being able to carry data into the Simscape component from originally a csv file (17x10 doubles).
I don't necessarily need it to be routed like it is now, so if there is a way which is more direct but works that would be okay too.
Is there any way to do what I am trying to do and if so how?
If this is not possible I won't be able to simulate the system that I have/need as the gas related simscape components are not nearly advaned enough for what I want to do.
0 Comments
Accepted Answer
Ashok
on 18 Oct 2024
Physical signals are scalars by default, meaning they have a 1x1 dimension. To work with physical signals of higher dimension, the ‘PS Signal Specification’ block can be used. It allows for explicit specification of the signal’s size and unit. Here is an example.
I have assumed that the signal from Simulink is a constant matrix. However, it can be replaced by a time varying matrix signal. For more information about the block, you can refer the following documentation page:
I believe this will assist you!
0 Comments
More Answers (0)
See Also
Categories
Find more on Gas Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!