How do I declare a variable in the MATLAB workspace from a MATLAB function?
Afficher commentaires plus anciens
I wrote a function that provides some variables to Simulink. I have declared them global, so Simulink could see them. But I have to declare them at the prompt and I am unable to declare them in the function because Simulink does not see them.
Réponse acceptée
Plus de réponses (1)
Gaganjyoti Baishya
le 20 Juin 2020
0 votes
Hi,
You can easily add variables in base from function using assignin.
function myFunc(a,b)
x=3;
assignin('base','myVar',x);
end
assignin declares the varibale myVar with value of 3.
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!