How to pass name-value-pair arguments to templateTree() as a struct?
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I am trying to group multiple name-value pair arguments and pass them to templateTree() as one. The usual call would be, e.g.:
templateTree('Surrogate','off','Prune','on','QEToler',1e-10)
I would like something like this:
opts = struct('Surrogate','off','Prune','on','QEToler',1e-10)
templateTree(opts)
If I try that the following error is shown:
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in classreg.learning.FitTemplate.make (line 38)
            [usertype,~,modelArgs] = ...
Error in templateTree (line 120)
temp = classreg.learning.FitTemplate.make('Tree',varargin{:});
So if templateTree() cannot handle structs as input arguments, is there another way to achieve the same thing? Or is this somehow possible with structs?
Thanks!
2 comentarios
  Alex Ryabov
 el 2 de Jul. de 2020
				You neet to convert it into name value pairs, 
see here 
Respuestas (1)
  Sugar Daddy
      
 el 2 de Jul. de 2020
        
      Editada: Sugar Daddy
      
 el 2 de Jul. de 2020
  
      Daddy Views
T_T= templateTree('Surrogate','off','Prune','on','QEToler',1e-10);
opts = {'Surrogate','off','Prune','on','QEToler',1e-10};
T_T_O = templateTree(opts{:});
Now check if they are equal
assert(isequal(T_T_O,T_T))
0 comentarios
Ver también
Categorías
				Más información sobre Functions 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!



