필터 지우기
필터 지우기

Run a function with input arguments using App Designer

조회 수: 22 (최근 30일)
Rishi Balasubramanian
Rishi Balasubramanian 2020년 12월 31일
댓글: Mario Malic 2020년 12월 31일
I have a MATLAB script file (.m file) which is a function
%It begins like this
function M = qcldpc(j, k, a, b, p)
I am trying to create an application that can run multiple of such .m files using app designer.
I want to get the input parameters from the user to be run in the function file. How do I do this. I am brand new to app designer and would love some pointers. Thank You
  댓글 수: 2
Mario Malic
Mario Malic 2020년 12월 31일
If you do the few examples that are available in App Designer, you'll get an idea what do you need to do.
Rishi Balasubramanian
Rishi Balasubramanian 2020년 12월 31일
Yeah, I got it thanks. Now I have another trouble.
%This function uses a script qcldpc to calculate 2 outputs that I need to be using in another function...
function CreateButtonPushed(app, event)
j = app.RowjEditField.Value;
k = app.ColumnkEditField.Value;
a = app.oaEditField.Value;
b = app.obEditField.Value;
p = app.SizeofIxEditField.Value;
[B,M] = eval('qcldpc(j, k, a, b, p)');
app.UITable.Data = B;
end
I need to use the output I got using eval in this to the next function
function SimulateButtonPushed(app, event)
db = app.SNRLimitEditField.Value;
it = app.IterationsEditField.Value;
msg = eval('Final(M,db, it)');
end
But there is an error message displaying saying that
%Error using eval
%Unrecognized function or variable 'M'.
I figured out that it had something to do with the Public property thingy. Can you point me out to the right method to do this? Thanks in advance.

댓글을 달려면 로그인하십시오.

채택된 답변

Mario Malic
Mario Malic 2020년 12월 31일
Great work, thank you for doing those.
You can set your variables into the property of the app and you'll be able to use those in other callbacks, functions etc. Public properties allow access to their values outside of app, private do not.
% Verify if properties block is correctly written
properties (Access = private)
M
end
function CreateButtonPushed(app, event)
j = app.RowjEditField.Value;
k = app.ColumnkEditField.Value;
a = app.oaEditField.Value;
b = app.obEditField.Value;
p = app.SizeofIxEditField.Value;
[B, app.M] =qcldpc(j, k, a, b, p);
app.UITable.Data = B;
end
function SimulateButtonPushed(app, event)
db = app.SNRLimitEditField.Value;
it = app.IterationsEditField.Value;
msg = Final(M,db, it);
end
  댓글 수: 2
Rishi Balasubramanian
Rishi Balasubramanian 2020년 12월 31일
Wow, that was straightforward and simple. I have been complicating things. Thanks a ton.
Mario Malic
Mario Malic 2020년 12월 31일
Also, a warm reminder from all of us here, don't use eval. Have a great day.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by