MATLAB: Try and catch help

catchguidetry

In a callback function of a GUIDE gui, I have:
path = get(handles.path_text,'String')
try
data = importdata(path,'')
if istruct(data)
x_k = data.data;
else
x_k = data;
end
x_k_length = length(x_k);
catch err
error(end+1) = {'Error: Invalid input path.'};
fail_status = onfail(handles.check_path);
end
The idea here is if the input path is invalid, it will be caught and handeled so the callback function can continue. However, for some reason, when MATLAB executes the IF statement, it goes to the catch block. I don't understand why.

Best Answer

OOPS! should be two s's in isstruct.
getReport(err) in the catch block allowed me to solve it.