How to stop matlab M file from stopping my program when error occur?

2 ビュー (過去 30 日間)
Kyle
Kyle 2011 年 7 月 12 日
Hi,
This code at certain input and base points will prompt an error like below. However my code loop the maketform 100 times each time with different combination of input and base point.
How do i stop the program from stopping my loop? i want to let it to loop finish 100 times. If an error occur it will return a 0 tform2 value or return other value that i could use as a condition when error occur.
tform2 = maketform('affine',input_points,base_points);
??? Error using ==> maketform>construct_matrix at 417 Collinear points in U or X; cannot continue.
Error in ==> maketform>affine at 158 A = construct_matrix( U, X, 'affine' );
Error in ==> maketform at 126 t = feval(fcn,varargin{2:end});

採用された回答

Walter Roberson
Walter Roberson 2011 年 7 月 12 日
try
tform2 = maketform('affine',input_points,base_points);
catch
tform2 = 0;
end

その他の回答 (3 件)

Sean de Wolski
Sean de Wolski 2011 年 7 月 12 日
doc try
use a try/catch block

Paulo Silva
Paulo Silva 2011 年 7 月 12 日
%inside your loop
try
%put here the code that might fail
catch
%do something if error occurs
end

Kyle
Kyle 2011 年 7 月 12 日
Thanks Sean , Paulo and Roberson.
U guys safe my day. For a sec i thought i need to modify the .m file.

カテゴリ

Help Center および File ExchangeFiles and Folders についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by