I would like to know if it's possible to use a colon ":" as argument of a function.
Something like that:
function  y=func(x)
  if x is a colon
    do this
  else
    do that
  end
Also is it possible to pass the key work end as argument of a function, and also 1:end, 3:end-5, etc... I doubt it's possible, but I would like to be sure.
Also, I get a weird error when I pass "1:end" as argument of a function, it produces no error, but inside the function, no argument is assigned (not even the other arguments). Do someone know what happens?
You can override both for your own classes:
classdef MyClass
properties(Access=public)
    data
end
methods
    function out = end(A,k,n)
         disp(A);
         disp(k);
         disp(n);
         out = [];
    end 
    function B = subsref(A,S)            
        disp(S);
        B = [];
    end
end
end
As for functions, I never heard of such a functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With