for loop 実行中のエラー処理について
    7 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    雅晶
 el 27 de Oct. de 2022
  
    
    
    
    
    Comentada: 雅晶
 el 1 de Nov. de 2022
            for i = 1:5
for loop 実行中に i = 2 でエラーが発生した場合、 i = 2 はエラーということで処理し、
 i = 3 やその後も実行を継続していくためにはどうすればよいですか。
0 comentarios
Respuesta aceptada
  Kojiro Saito
    
      
 el 27 de Oct. de 2022
        tryの中でエラーになっても処理が中断せず、catchの中でエラー処理をハンドルできます。
for n=1:5
    try
        disp(n)
        if n==2
            surf %入力引数無しでエラーとなる
        end
    catch ME
        disp(ME) % Exceptionを表示
    end
end
Más respuestas (0)
Ver también
Categorías
				Más información sobre ループと条件付きステートメント 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!
