If statment with multiple conditions
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Caprice Corlew
 el 3 de Oct. de 2014
  
    
    
    
    
    Editada: Mohammad Abouali
      
 el 3 de Oct. de 2014
            I have to make an if elseif else statement where if pertains to three options I put
    answer=menu('Select a curve type','a) Square wave','b)Sine wave' ...
               ,'c)Cosine wave','d)Tangent curve','e)Decaying exponential');
        if answer==1,2,3
            frequency=input('Enter a frequency');
            amplitude=input('Enter an amplitude');
            cycles=input('Enter a number of cycles');
        elseif answer==4
            frequency=input('Enter a frequency  \n');
            cycles=input('Enter a number of cycles  \n');
        else answer==5
            tau=input('Enter a time constant');
        end
what should I do to make it work?
0 comentarios
Respuesta aceptada
  Mohammad Abouali
      
 el 3 de Oct. de 2014
        
      Editada: Mohammad Abouali
      
 el 3 de Oct. de 2014
  
      if any(answer==[1,2,3])
  frequency=input('Enter a frequency: '); 
  amplitude=input('Enter an amplitude: '); 
  ccycles=input('Enter a number of cycles: '); 
elseif (answer==4) 
  frequency=input('Enter a frequency: '); 
  cycles=input('Enter a number of cycles: '); 
elseif (answer==5)
  tau=input('Enter a time constant: '); 
else
  error('some error');
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Control System Toolbox 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!

