I'm trying to make an app from my .mlx file.
In .mlx I have the following snippet of code:
a = 50;
b = 60;
aP = [];
bP = [];
[aP,bP] = dosomething(a,b);
function [raP,rbP] = dosomething(x,y)
i = 0:pi/3:2*pi-pi/3;
Za = 0*i;
Xa = cos(i)*x;
Ya = sin(i)*x;
raP= [Xa;Ya;Za];
j = 0:pi/3:2*pi-pi/3;
Zb = 0*j;
Xb = cos(j)*y;
Yb = sin(j)*y;
rbP = [Xb;Yb;Zb];
end
However, when I try to use it in .mlapp as such:
properties (Access = private)
a
b
aP
bP
end
methods (Access = private)
function [raP,rbP] = dosomething(x,y)
i = 0:pi/3:2*pi-pi/3;
Za = 0*i;
Xa = cos(i)*x;
Ya = sin(i)*x;
raP= [Xa;Ya;Za];
j = 0:pi/3:2*pi-pi/3;
Zb = 0*j;
Xb = cos(j)*y;
Yb = sin(j)*y;
rbP = [Xb;Yb;Zb];
end
function startupFcn(app)
app.a = 50;
app.b = 60;
app.aP = [];
app.bP = [];
[app.aP,app.bP] = dosomething(app.a, app.b);
end
end
I get the following error:
Undefined function 'dosomething' for input arguments of type 'double'.
Incorrect number or types of inputs or outputs for function 'dosomething'.
Error in test/startupFcn (line 45)
[app.aP,app.bP] = dosomething(app.a,app.b);
Error in matlab.apps.AppBase/runStartupFcn (line 68)
ams.runStartupFcn(app, startfcn);
Error in test (line 79)
runStartupFcn(app, @startupFcn)
In the .mlx the a and b variables are also doubles so what's the fuss?

 채택된 답변

Walter Roberson
Walter Roberson 2023년 3월 9일

1 개 추천

Methods of your class must accept an app as parameters, unless they are declared as static methods.
static methods can have any inputs you want.
methods (Access = private)
You should consider just creating private/something.m in the directory you define the class in.

댓글 수: 1

Thank you for your answer, it is the solution to this problem!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Parallel Server에 대해 자세히 알아보기

제품

릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by