APP DESIGNER - How to try and catch TeX syntax?

조회 수: 4 (최근 30일)
Tor Hadas
Tor Hadas 2016년 4월 20일
답변: Roger Parkyn 2019년 6월 10일
I have a uiaxes component and an uieditfield component.
I want the user to be able to change the uiaxes' title using the edit field, in TeX syntax.
My problem is everytime I try to write a wrong TeX syntax string, an error pops out.
I want to be able to catch the error and display an error to the user if the syntax is wrong, instead of matlab going crazy.
This is my code:
try
title(app.MyAxes, app.MyEditField.Value);
catch
SetError(app, 'Invalid TeX syntax');
end
(SetError is a function I made to diplay errors to the user)
this does not work - instead I get this error:
Error using appdesigner.internal.appdesignererrorcallback (line 8)
Error updating Text.
String must have valid interpreter syntax:
MyWrongSyntaxTitle{
Error in appdesigner.internal.service.AppManagementService/axeserrorhandler (line 138)
appdesigner.internal.appdesignererrorcallback(event.Source, event);
Error in appdesigner.internal.service.AppManagementService>@(source,event)obj.axeserrorhandler(event,app) (line 132)
@(source, event)obj.axeserrorhandler(event, app);
Error while evaluating HTMLCanvas ErrorCallback
(MyWrongSyntaxTitle{ is the text I put in the edit field to test the try-catch)
What am I doing wrong? How can I catch this error?
(SetError is never called)

답변 (1개)

Roger Parkyn
Roger Parkyn 2019년 6월 10일
I don't know the answer to your specific quesion but this may help others using appdesigner:
try
some_code; % You can put it around quite large chunks of code so that, at least, it fails more informatively
catch ME % ME is of the class MException (in-built Matlab)
str = sprintf(['Something is wrong with the plotting code. \n' 'Matlab says: \n' ME.message]);
uialert(app.UIFigure, str, 'Plotting Problem');
end

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by