Hi 张力翰 刘,
由于我的母语不是粤语,我将尝试用英语回答这个问题。感谢您的理解。
As I understand, you would like to hint in advance about the type of element inside a class. In MATLAB, you can provide type hints using comments to help the editor understand the type of elements inside a cell array. This can improve code completion and provide better support for class methods. Here's how you can do it:
% Assume myClass is the class you've defined
% Create a cell array
a = cell(1, 100);
% Initialize instances of myClass in each cell
for i = 1:100
a{i} = myClass(); % Initialize with an instance of myClass
end
To provide a type hint to the MATLAB editor, you can use a comment to specify the type of elements inside the cell array:
%{
a: cell array containing instances of myClass
a{1}: myClass
%}
a{1}. % After typing the dot, the editor should provide code completion for methods of myClass
By adding this type hint comment, you can help the MATLAB editor understand the type of elements inside the cell array a. This should enable better code completion and method suggestions for the class 'myClass'.
Hope this helps!