How to concatenate scalar variables from every time step using a Matlab function block in Simulink
1 次查看(过去 30 天)
显示 更早的评论
Hi, I have a model which outputs x and y co-ordinates every time step. As the simulation runs I wish to create a vector of all of the scalar co-ordinates outputted so far. Obviously the length of the vector will increase by 1 every time step. I then want to use the vector to create a polygon and look for intersections.
if x is the input x co-ordinate and xv is the concatenated vector I have been trying to use:
xv=vertcat(xv,x)
xv is defined as a global variable so that it is stored each time the function is called and I have also tried defining it as variable length using 'coder.typof' but this hasn't worked.
The error I run into is in handling the variable xv because it has a variable length.
Any suggestions as to how to tackle this? I'm sure the answer must be simple!
Thanks
0 个评论
回答(1 个)
Jorik
2014-12-4
In Simulink a variable-size signal (or variable in a MATLAB Function block) must always have an upper bound to the size. Do you really want to have the increasing variable size as an output signal of your block? It may might more sense to process the yout logged output signal variable after the model has completed?
If you do need all the previous sample values as an output signalin the model, you could use the Tapped Delay block with a sufficiently large "Number of delays" parameter value.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!