How can I use set_param to set StartFcn from within a class method?
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Matthew Drummond-Stoyles
 el 4 de Mayo de 2020
  
    
    
    
    
    Comentada: Matthew Drummond-Stoyles
 el 13 de Mayo de 2020
            I am trying to use
set_param(app.Model,'StartFcn','app.registerListeners')
but the code when run inside StartFcn doesn't recognize 'app' or 'registerListeners'. 'app' is a parameter of the method this is called from, and 'registerListeners' is a public method in the same class.
I have tried:
- Using a callback instead of putting the third argument in single quotes - says 'Invalid setting for block diagram parameter 'StartFcn'
0 comentarios
Respuestas (1)
  Sai Sri Pathuri
    
 el 7 de Mayo de 2020
        Can you add the error being thrown when you use 'app.registerListeners(app)' as the third parameter?
If this is the error,
The class app has no Constant property or Static method named 'registerListeners'.
 you may try to convert registerListeners function to static to use it as a start function. Also, try to check if app and model are in same folder or add the folder containing app to the MATLAB path.
6 comentarios
  Tommy
      
 el 11 de Mayo de 2020
				While possibly not the best solution, is the following an option?
assignin('base', 'app', app);
set_param(app.Model, 'StartFcn', 'app.registerListeners');
Ver también
Categorías
				Más información sobre Programmatic Model Editing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


