passing a colon as argument of a function in matlab

前端 未结 2 390
抹茶落季
抹茶落季 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: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.

提交回复
热议问题