How do you declare structures within classes?

4 ビュー (過去 30 日間)
Steven
Steven 2015 年 1 月 23 日
コメント済み: per isakson 2015 年 1 月 26 日
I want to nest a class inside of a class or a struct inside of a class:
classdef class1
properties
Commands = struct(...
'functionResetTime' ,1,...
'CtrlTestData' ,9 ...
)
x =3;
end
methods
end
end
I want to do this because I have about 20 structs that I would like to use the automatic tooltyping (. and then tab) when I write code. Kind of like .net. I don't want to have to create a file for each of these structs or import them. The method describe above doesn't work and you can't just declare a struct anymore (why? I don't know).

回答 (2 件)

per isakson
per isakson 2015 年 1 月 23 日
編集済み: per isakson 2015 年 1 月 23 日
"method describe above doesn't work" &nbsp I don't understand how you want it to work. That's might be because I don't know the .NET-behavior. However,
&nbsp
and if I instead do
class1 = class1; % which smells
&nbsp
  1 件のコメント
per isakson
per isakson 2015 年 1 月 26 日
This example is done with R2013b.

サインインしてコメントする。


Steven
Steven 2015 年 1 月 26 日
ok, this was working in 2014b but not 2014a, plus in 2014a if you push f5 to test the class syntax it did not replace the original declaration of class1 and kept all the original variables

カテゴリ

Help Center および File ExchangeClasses についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by