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?

 Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Mzo. de 2023
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 comentario

Aleksander Gnat
Aleksander Gnat el 9 de Mzo. de 2023
Thank you for your answer, it is the solution to this problem!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Sudoku en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by