readmatrix error handling in Simulink Matlab function
3 ビュー (過去 30 日間)
I'm using the 'readmatrix' function inside a matlab function block in Simulink to read an Excel file that is often updated by an external software.
Simulink is sometimes crashing because it doesn't has access to the Excel file but I want Simulink to ignore this error and retry to read the file in the next simulation step.
I tried using a try/catch statement but this seems not to be available in Simulink.
All it needs to do is to try to access the file again instead of throwing an error and breaking the simulation, anyone who can help witrh this?
Paul 2023 年 8 月 17 日
Try using exist:
function y = fcn(u)
fileexists = 100.0; % dummy assignment to specify fileexists type for code generator
fileexists = exist('fu.xlsx','file');
if fileexists == 2
y = u;
y = -u;