passing a colon as argument of a function in matlab

前端 未结 2 389
抹茶落季
抹茶落季 2021-01-18 04:50

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         


        
相关标签:
2条回答
  • 2021-01-18 05:25

    No, it's not possible to pass a colon as an argument (it doesn't make any sense).

    0 讨论(0)
  • 2021-01-18 05:30

    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.

    0 讨论(0)
提交回复
热议问题