Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

try-catch function

20 views
Skip to first unread message

Fred

unread,
Apr 16, 2012, 4:40:01 AM4/16/12
to

Hi.

I am trying to get informations in a txt file. But if that information
is not present, I want the sript to give another information. So I use
the try-catch functions. But it doesn't work properly.
Does anyone know where is my problem ?

//////////////

NumPiece=X0(1,1);

try
data=fscanfMat('MESURE-FB.TMP');
choix=data(data(:,1)==NumPiece,:);
catch
pause
choix=[NumPiece,-1000,-1000];
end

choix

Serge Steer

unread,
Apr 16, 2012, 9:07:04 AM4/16/12
to
In your case the try instruction does not produce an error (at least if
the MESURE-FB.TMP file exists). So the catch instruction are not called

I think the following code should do the job:
NumPiece=X0(1,1);
data=fscanfMat('MESURE-FB.TMP');
choix=data(data(:,1)==NumPiece,:);
if choix==[] then
choix=[NumPiece,-1000,-1000];
end

Serge Steer
0 new messages