How can I call a function inside a class in the command window?

47 visualizaciones (últimos 30 días)
Jay
Jay el 4 de Abr. de 2020
Respondida: SaiDileep Kola el 9 de Abr. de 2020
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
Jay
Jay el 5 de Abr. de 2020
What if the code is like that? The input argument "value" is a .txt file.
classdef my_class
properties
prop
end
methods
function [output,value] = my_function (obj,input,value)
prop1 = obj.prop(1);
prop2 = obj.prop(2);
prop3 = obj.prop(3);
in1 = input(1);
in2 = input(2);
in3 = input(3);
end
end
end
Ameer Hamza
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.

Iniciar sesión para comentar.

Respuestas (1)

SaiDileep Kola
SaiDileep Kola el 9 de Abr. de 2020
In addition to above going through this linkwould help you ramp up using classes in MATLAB.

Categorías

Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by