Problem with assigning properties to object array in class

조회 수: 4 (최근 30일)
J. Hu
J. Hu 2013년 9월 29일
답변: J. Hu 2013년 9월 29일
Why I got error message for following code and how can I fix it? Thanks...
ObjArray.m: clear all; clc
A= {'a',2;'V',3};
Obj = ObjArrayClass(A);
ObjArrayClass.m:
classdef ObjArrayClass properties c1 c2 end
methods
function Obj = ObjArrayClass(A)
% Obj = struct; % Doest not help
% Obj = cell(size(A),1); % Doest not help
% size(A,1)
for iRow=1:size(A,1)
Obj(iRow).c1 = A(iRow,1);
Obj(iRow).c2 = A(iRow,2);
end
end
end
end

답변 (1개)

J. Hu
J. Hu 2013년 9월 29일
if nargin ~= 0 % Allow nargin == 0 syntax
end
then it works. Why? It does not change anything. Strange.

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by