How do I use Simulink-PS Converter with a data vector importet from Matlab workspace?
12 次查看(过去 30 天)
显示 更早的评论
I would like to perform a part of my Matlab simulation in Simulink. Therefore, I am using the From Workspace and To Workspace blocks to share the data. By using the Simulink-PS Converter block right after the From Workspace block, as shown ins this simnplified schematic
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168632/image.png)
only constant values can be used. Example using a constant Value 1:
WSDataIn = [0 1];
a = sim('PS_Test','SimulationMode','normal');
Example Using a vector [1 1]:
WSDataIn = [0 1 1];
a = sim('PS_Test','SimulationMode','normal');
The following error massage appears:
Error due to multiple causes.
Caused by:
Error in port widths or dimensions. Output port 1 of 'PS_Test/From Workspace' is a one
dimensional vector with 2 elements. Error in port widths or dimensions. Input port 1 of
'PS_Test/Simulink-PS Converter' is a one dimensional vector with 1 elements.
A sine wave block in simulink is also time-variant and works with the converter. How can I use Simulink-PS Converter with a data vector importet from Matlab workspace? Because I would linke to use a precalculated signal as a signal source.
0 个评论
采纳的回答
Birdman
2017-10-23
编辑:Birdman
2017-10-23
Try this model instead. In your model, the from workspace block provides constant data throughout the simulation which is 1x1 scalar value. If you make the input data nx1, you need all your block to accept nx1 vector but it is not possible. However, I edited your model where you can define different inputs depending on the length of the simulation time. I used a MATLAB Function. See this model and I hope it helps.
Do not forget, if your signal is precalculated, it has to be the same length with the simulation time!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!