MATLAB: Undefined operator ‘*’ for input arguments of type ‘cell’

undefined operator

I am getting this error-"Undefined operator '*' for input arguments of type 'cell'".
for i=1:length(matrix.rxnIDs)
if strcmp(matrix.mettype(i),'reactant')
matrix.metcoef(i) = matrix.metcoef(i).*-1;
end
end

Best Answer

matrix.metcoef{i} = matrix.metcoef{i} .* -1
matrix.metcoef{i} = -matrix.metcoef{i}; % SIMPLER
% ^ ^ ^ ^ Use the correct brackets
Read about the different ways to access cell arrays:
Remember:
  • () parentheses access the cells themselves.
  • {} curly braces access the cell contents.