Por que recebo um erro "Muitos argumentos de entrada" ao transmitir parâmetros apropriados?
Por que estou recebendo um erro:
??? Erro ao usar ==> ensureCellType Muitos argumentos de entrada.
Erro em ==> usage_dynamicVariableNaming em 11 result = dataHolder.ensureCellType (str);
quando eu estou passando no número certo de parâmetros?
% USAGE:
clear all;
clc;
elementNames = {'area_12345[<>]6789', 'apollo123', 'guruX', 'ok'};
elementTypes = {'string', 'specialChar', 'int', 'float'};
elementValues = {'charlie', 'vvv', '09', '123.321'};
dataHolder = dynamicVariableNaming;
str = 'test';
result = dataHolder.ensureCellType(str);
%% CLASS
classdef dynamicVariableNaming
%HELLO Summary of this class goes here
% -
properties
variableNames = [];
variableValues = [];
variableTypes = [];
end
methods (Access = public) % (Access = private)
function obj = dynamicVariableNaming (variableName, variableValue, variableType)
% class constructor
if(nargin > 0)
obj.variableNames = variableName;
obj.variableValues = variableValue;
obj.variableTypes = variableType;
end
end
% end
%
% methods (Static = true)
function addVariables (obj, variableName, variableValue, variableType)
obj.variableNames = [obj.variableNames ensureCellType(variableName)];
obj.variableValues = [obj.variableValues ensureCellType(variableValue)];
obj.variableTypes = [obj.variableTypes ensureCellType(variableType)];
end
function cellData = ensureCellType(value)
if (class(value) ~= 'cell')
cellData = cell2string(value);
else
cellData = value;
end
end
end
end
Obrigado pela sua grande ajuda. Agora ele é executado, mas os dados não são inseridos.
Eu comecei uma nova discussão sobre este novo problema:Os dados não são inseridos com sucesso no objeto