Effacer les filtres
Effacer les filtres

Cambiar variable de Simulink desde MatLab

1 vue (au cours des 30 derniers jours)
Celia Sanchez-Giron
Celia Sanchez-Giron le 27 Juin 2022
Réponse apportée : Aditya le 27 Oct 2023
Buenas,
Tengo una variable de tipo matriz K_LC (18,1) en la que guardo 18 articulaciones de un robot humanoide. Esta la he definido en MatLab y quería dar un valor al número K_LC(1,1) por ejemplo que es la articulacion del hombro:
K_LC(abs(H.eje.HomDF))= -8*sign(H.eje.HomDF);.
Para ello quería que se cumpliera una condición en Simulink, de forma que si una variable que tengo es mayor que cero, entonces se asigna a K_LC(1,1), que es lo mismo que K_LC(abs(H.eje.HomDF), un número en función del valor de la articulación que sea -8*sign(H.eje.HomDF).
Quería saber qué puedo poner en Simulink para definir que si se cumple que una variable es mayor que cero, entonces asigno un nuevo valor a la variable K_LC(1,1). Lo he intentado con Data Store pero no me reconoce la vairable K_LC que he definido previamente en MatLab y que es la que quiero cambiar.
Muchas gracias de antemano.
Un saludo!!!

Réponses (1)

Aditya
Aditya le 27 Oct 2023
Hi Celia,
I understand that you would like to update variables using Simulink. To achieve this, you can create a Simulink Model Workspace.
To manipulate model workspace variables, you can use MATLAB commands on a Simulink.Workspace variable. Please refer to the following documentation for guidance on how to accomplish this in your specific case:
Regarding where to place these commands, it depends on your scenario. If the variables only change at the end of the simulation and should be used for the next simulation, you can put the commands in the "StopFcn" callback.
If the variables change EVERY time step during the simulation, try putting it in a MATLAB function block since this would execute every time step.
Hope this information helps you in resolving your query!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!