Why am I getting an error:
??? Error using ==> ensureCellType Too many input arguments.
Error in ==> usage_dynamicVariableNaming at 11 result = dataHolder.ensureCellType(str);
when I am passing in right number of parameters?
% 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
Thanks for your great help. It now runs, but the data is not inserted.
I started a new thread on this new issue: The data is not inserted successfully into object