zoukankan      html  css  js  c++  java
  • matlab中 @文件夹名/+文件夹名 的含义

    matlab中带“+”和“@”字符命名的文件夹是matlab中的一种文件包, 比如:+folder/Tata.m ,matlab就知道这是一个Tata类文件夹;如果你按照普通的命名方式,比如:someOtherFolder/Tata.m ,或者someOtherFolder/@Tata/Tata.m ,这样matlab只能知道这是一个Tata.m文件。

            如果你要用classdef定义一些类,用@Tata的形式,可以把一些方法分别放在不同的路径目录下。以下的例子进一步阐明@目录的用法: Tata 类,方法methodOne 和 methodTwo

    somePlaceOnThePath/@Tata/Tata.m
    somePlaceOnThePath/@Tata/methodOne.m
    somePlaceOnThePath/@Tata/methodTwo.m

    你也可以把所有用到的方法放在一个单独的文件中:

    somePlaceOnThePath/Tata.m

    如果你所写的方法比较复杂,而你又想把它放在不同的文件中以方便查阅和管理,可以如下般使用classdef

    文件一:

    %# somePlaceOnThePath/@Tata/Tata.m:
    classdef Tata
        methods
             result =methodTwo(obj,arg)
             functionmethodOne(obj)
                 disp('hello from methodOne');
             end
        end
    end

    文件二:

    %# somePlaceOnThePath/@Tata/methodTwo.m:
    functionresult =methodTwo(obj,arg)
    %dostuff withobj andarg
    end

    严格来讲,methodTwoclassdef中的声明是可以省略的,因为这里使用了默认的说明符。如果想把methodTwo作为私有方法,可以用 (Access = private) 

    参考资料:http://stackoverflow.com/questions/9781866/folder-and-folder-in-matlab

  • 相关阅读:
    csp2020游记
    agc006_f Blackout
    CF1368G Shifting Dominoes
    AtCoder Grand Contest 009 简要题解
    Codeforces Round #666 (Div. 1)
    CSP 2019 树的重心
    Luogu-P4859 已经没什么好害怕的了
    2020.9.17 校内测试
    CF379F New Year Tree
    图论(小结论)
  • 原文地址:https://www.cnblogs.com/jmpep/p/4486346.html
Copyright © 2011-2022 走看看