Is it possible to write to a MATLAB workspace parameter from within a TLC file?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm generating a level-2 matlab s-function based on a m file and it is working perfectly since I'm able to modify workspace variable from m file.
However, when I generate code or simulate in accelerator mode, I need to provide a tlc file that does the same thing than the m file and I have hard time to do so. I'm not able to modify a workspace variable from the tlc.
I tried the following :
%assign b = FEVAL("evalin","base","var1 = 10")
But it doesn't work. It is based on the following post: http://www.mathworks.com/support/solutions/en/data/1-D4U5ES/index.html?product=RT&solution=1-D4U5ES
Thanks for your help.
David.
0 commentaires
Réponses (2)
Kaustubha Govind
le 1 Oct 2012
Modifié(e) : Kaustubha Govind
le 1 Oct 2012
I'm guessing this is not working, because you are doing the equivalent of:
>> b = evalin('base','var1 = 10')
When executed in the MATLAB command window, I see this error:
>> b = evalin('base','var1 = 10')
Error: The expression to the left of the equals sign is not a valid target for an assignment.
Try just:
%<FEVAL("evalin","base","var1 = 10;")>
2 commentaires
Kaustubha Govind
le 2 Oct 2012
David: What exactly is the code generating around line#33 of two_acc.c? This file may be hard to read, so I would recommend performing a regular code-generation (Ctrl+B) and see if you can reproduce the same error?
Juan Reyes
le 15 Juil 2016
I had the same problem. Try this inside your TLC code:
%matlab assignin("base", "YourWorkspaceVar", %<foo> )
base: Matlab's base workspace; YourWorkspaceVar: Workspace new variable; foo: a variable inside the TLC workspace to be exported to base workspace;
0 commentaires
Voir également
Catégories
En savoir plus sur Simulink Coder 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!