function [m,s] = twoStats(x) arguments x (1,:) {mustBeNumeric} end m = mean(x,"all"); s = std(x,1,"all");end
Define Name-Value Arguments
function myRectangle(X,Y,options) arguments X double Y double options.LineStyle (1,1) string = "-" options.LineWidth (1,1) {mustBeNumeric} = 1 end % Function code ...end
% THIS ARE ALL VALIDmyRectangle(4,5)myRectangle(4,5,LineStyle=":",LineWidth=2)myRectangle(4,5,LineWidth=2,LineStyle=":")myRectangle(4,5,LineStyle=":")myRectangle(4,5,LineWidth=2)
Or how i liked to do it:
function myRectangle(X,Y,LineStyle,LineWidth) arguments X double Y double LineStyle.LineStyle (1,1) string = "-" LineWidth.LineWidth (1,1) {mustBeNumeric} = 1 end Function code ...end