Update variable value to workspace
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to run the following funtion with input u
function output = statespaceEqn(u) %#codegen
coder.gpu.kernelfun()
S = coder.load('matrix.mat');
S.x = S.A*S.x+ S.B*u; %% State Equation
output = S.C*S.x+ S.D*u; %% Output equation
end
I used coder.laod to load my variables 'A' 'B' 'C' 'D' 'x' from my mat file
I defined the variable x with zeros(321,1), but now I want the variable x to be updated with the new value once I run my function.
Could anyone help me to figure this out.
1 commentaire
KSSV
le 17 Juin 2020
Load the mat file and pcik x from it in the workspace, out side the function. Won't it work?
Réponses (1)
Sayyed Ahmad
le 17 Juin 2020
I would try to load my variables by useing PostLoad callbacks in model Properties.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/317805/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/317808/image.jpeg)
Now you have access to this variables by uisng function evalin or assignin. The workspace for your variables in this case would be 'Base'.
0 commentaires
Voir également
Catégories
En savoir plus sur Transportation Engineering dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!