Multiple if elseif statement
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
rakesh kumar
el 5 de Abr. de 2021
Comentada: rakesh kumar
el 5 de Abr. de 2021
How to write multiple if else if statement . Is there any vectoristion method for it. I want to write the statement five hundred times.
2 comentarios
KSSV
el 5 de Abr. de 2021
if else can be replaced by using indexing most of the time. Read about it.
Respuesta aceptada
Steven Lord
el 5 de Abr. de 2021
It depends on what you're trying to do. If you want to do something like:
- If x is between 0 and 1, in the range [0, 1), let y be some value
- If x is between 1 and 2, in the range [1, 2), let y be a different value
- If x is between 2 and 3, in the range [2, 3), let y be a third value
- etc
consider using the discretize function or use a for loop over the intervals or use findgroups and splitapply or use groupsummary or ...
If you give us more detailed information about what you're trying to do we may be able to offer more specific suggestions.
Más respuestas (1)
Sajid Afaque
el 5 de Abr. de 2021
you can try switch statements as alternative for else if.
depends on your need
0 comentarios
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices 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!