Sample Time and simOut Interaction
8 次查看(过去 30 天)
显示 更早的评论
Hey Guys
so i have a Simulink-Simscape model that runs for 5 sec. During the time i have a Transform sensor measuring the distance between 2 points. This x,y,z-coordinates are saved in my workspace with simout (To Workspace). The problem is that this matrix varies between the size 900x3 and 1300x3, depending on the parameters of my Block. I think the matix size changes because the automatic generated sample time is changing because of parameter changes. I want the matrix to always be 1000x3, no matter how my model changes. So i got to Model Settings and changed the Solvertype from "Variable-step" to "Fixed-step" and changed the the "Fixed-step size" to 5/1000 (or 0.005), to have 1000 steps over 5 sec. But when i run the model now, the model is not simulating and i dont know why the simout doesnt work with fixed-step. if i set the Fixed step size to "auto", the model is simulating but only with an output of 1x3
The other thing i tried is to leave it on Fixed-step size and just change Max, Min and Initial step size from "auto" to "0.005", but then its also not simulating
I hope my Problem is understandable
0 个评论
采纳的回答
Fangjun Jiang
2021-2-3
Usually it is because the fixed step size is too big for the model to simulate accurately.
There are many solution to this. The easiest is to specify the sample time of the "To Workspace" block to be 0.005.
10 个评论
Paul
2021-2-4
编辑:Paul
2021-2-4
What was the Sample Time of the To Workspace block in this run?
My result, 2019a, no additional To Workspace block, matches your result:
>> tout(tout>=9.5)
ans =
9.5000
9.6000
9.6842
9.7000
9.7414
9.7827
9.8000
9.8450
9.8886
9.9000
9.9483
9.9889
10.0000
My result, added To Workspace block on the alpha signal, Sample Time = 0.11
>> tout(tout>=9.5)
ans =
9.5000
9.5700
9.6000
9.6800
9.7000
9.7413
9.7827
9.7900
9.8000
9.8458
9.8894
9.9000
9.9482
9.9889
10.0000
which as hits at every 0.1 second and additional hits due to the 0.11 Sample Time in the To Workspace:
>> xx=0:.11:10;
>> xx(xx>=9.5)'
ans =
9.5700
9.6800
9.7900
9.9000
Fangjun Jiang
2021-2-4
Okay, I got the point now. I agree with you completely regarding "changing the sample time of a To Workspace block can definitely change the results of the simulation" and "the solver now has to hit the Sample Times of the To Workspace block when the Sample Time is changed from -1 to some positive value".
In my case, the added "To Workspace" block has a sample time of 0.1, which coinsides with an existing 0.1 sample time.
Also, in my previous comments regarding "weird" result, I was expecting that "tout" hits AND ONLY hits the 0.1 grid. Now I realize that should not be the expectation.
All is good. Thank you for your comments. It deepens my understanding of the topic.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Configure Simulation Conditions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!