How can I call a function inside a class in the command window?
Mostrar comentarios más antiguos
I'm new to matlab and I want to call a function contained inside a class in the comand window to run it. The method is not static. How can I do it? Also is there a simpler way to run the function? Also what is obj?
classdef my_class
properties
param
end
methods
function [x,y] = my_function(obj,a,b)
....
end
end
end
3 comentarios
You can create an instance of my_class,
A = my_class
and then call any public methods of my_class through that instance, such as
A.my_function(a,b)
I only passed two argument into my_function because the first argument (obj) is always the instance of the class, in this case A. It is similar to 'this' in Java or 'self' in Python. You don't have to call it obj - you could define your function as
function [x,y] = my_function(this,a,b)
....
end
if you wanted.
Jay
el 5 de Abr. de 2020
Ameer Hamza
el 5 de Abr. de 2020
Jay, is the value name of the .txt file (a char array)? You can still call any public method of a class using the syntax described by Tommy.
Respuestas (1)
SaiDileep Kola
el 9 de Abr. de 2020
0 votos
Categorías
Más información sobre Troubleshooting in MATLAB Compiler SDK en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!