check whather user input is given or Not and check the validation
    14 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    ORUGANTI SIVAMURALIKRISHNA
      
 el 8 de Jun. de 2020
  
    
    
    
    
    Comentada: ORUGANTI SIVAMURALIKRISHNA
      
 el 15 de Jun. de 2020
            I wrote a code and while executing it sometimes i will skip some inputs then it will continue to second line, whle computing it will show error and exit. so i want to eliminate ot by making sure the user given input and show him all the given inputs and giving cahncce to change them if required then continue can you please help
0 comentarios
Respuestas (2)
  Dhanush Bejjarapu
 el 8 de Jun. de 2020
        Do you mean that we need to give input for few parameters and they should be used for the next steps? 
  Walter Roberson
      
      
 el 8 de Jun. de 2020
        function varargout = YourFunction(varargin)
  argnames = {'x', 'y', 'n'};
  for K = 1 : length(argnames)
      if nargin < K || isempty(varargin{K}) || any(isnan(varargin{K}(:)))
          new_parameter = input( sprintf('Enter a value for %s ', argnames{K} ) );
          newargs = varargin;
          newargs{K} = new_parameter;
          [varargout{:}] = YourFunction(newargs{L});
          return
      end
  end
  %if you got here, your argument validation passed, so do your regular computation
end
3 comentarios
Ver también
Categorías
				Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


