Error while calling mlapp from function

조회 수: 1 (최근 30일)
Rohan Nadkarni
Rohan Nadkarni 2021년 7월 5일
답변: Pranjal Kaura 2021년 9월 2일
I have a function that is supposed to read text fields from a pdf, then calls an mlapp, then call an mlapp, then enter text fields from pdf and outputs of the mlapp into a new entry in a SQL table. I create outputs of the mlapp in the SubmitButtonPushed function using the syntax
assignin('caller','outputfrommlapp','Y')
Example of how the code looks is below.
function createDBEntryFromPDF(pdfname)
%code to read text fields from pdf
my_app_handle = manual_entry_app(textfrompdf1, textfrompdf2);
uiwait(my_app_handle.BreastMRManualEntryFormUIFigure);
conn = database('breastMRdb','','');
newentry = table(textfrompdf1, textfrompdf2, outputfrommlapp)
sqlwrite(conn,'table1',newentry)
end
However, when I call this function from the MATLAB Command Window like this
createDBEntryFromPDF("file1.pdf")
I get an error while creating newentry that variable outputfrommlapp doesn't exist. It is not an issue of the variable name being spelled wrong in the caller function createDBEntryFromPDF or in the mlapp. I thought the uiwait would resolve this issue, but it doesn't.
What else am I supposed to do so that outputfrommlapp can be added to the table in the 2nd to last line of the function without error?
Thanks,
Rohan Nadkarni

답변 (1개)

Pranjal Kaura
Pranjal Kaura 2021년 9월 2일
Hey,
It is my understanding that the callback of the button 'SubmitButtonPushed' is the caller to your function 'createDBEntryFromPDF'. Therefore using assignin('caller','outputfrommlapp','Y') in the callback of 'SubmitButtonPushed' would add a variable named 'outputfrommlapp' in the caller of the callback function (and not in the workspace of your 'createDBEntryFromPDF' function). Thus, there is no variable named 'outputfrommlapp' in the function 'createDBEntryFromPDF'. You can read more about the function assignin using the documentation.
A possible workaround could be to set the 'outputfrommlapp' as a private (or public) property of the app. You can read more about it here and here

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by