Saving variable of selected value from simulink matlab fcn to workspace
Mostrar comentarios más antiguos
Hi, I need to save a variable's value from a Matlab fcn block in simulink into workspace for use. But I only want to save the value under certain condition, so there's a IF statement , so something like ias_temp=0;
if(...)
ias_temp=input;
save ias_temp into workspace;
end
it's sort of like to create a memory where you can store a value and hold it over there until you rewrite to it next time.
In addition, I will be using the variable in the Matlab fcn block also, so I need to read the value saved in workspace.
Is there any way to do this? I've tried a lot of ways but they don't work as I wanted it.
Thanks!
yida
Respuestas (2)
Azzi Abdelmalek
el 8 de Ag. de 2013
assignin('base','variable_name',your_fcn_variable)
1 comentario
yida
el 8 de Ag. de 2013
Kaustubha Govind
el 8 de Ag. de 2013
0 votos
Is there a reason the value needs to be stored to the MATLAB workspace? You could either use a persistent variable if the value will only be used in the MATLAB Function block, or to share the data globally, see Share Data Globally.
2 comentarios
yida
el 9 de Ag. de 2013
Kaustubha Govind
el 9 de Ag. de 2013
yida: Could you paste some sample code on how you are using the persistent variable?
Categorías
Más información sobre Sources en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!