Error while processing model in Simulink

Hi all! I am trying to read one line from txt file in Embedded MATLAB Function block and convert this line to float:
t_r=0;
r=nan;
t_r=fopen('<path>','r')
r=scanf(temp_roll, '%f')
fclose(t_r)
Everything is good, but sometimes it can be line with letters and MATLAB catch next error:
An error occurred while running the simulation and the simulation was terminated Caused by: Size mismatch for MATLAB expression 'fscanf'. Expected = 1x1 Actual = 0x0
I have tried to use try-catch exceptions, but it isn't possible to use it in EMF. How can I solve my problem? I want to just ignore cases when line contains letters.

Answers (0)

Asked:

on 25 Mar 2016

Community Treasure Hunt

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

Start Hunting!