How to concatenate scalar variables from every time step using a Matlab function block in Simulink
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Jorik
le 4 Déc 2014
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 commentaires
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!