Undefined operator '*' for input arguments of type 'cell'

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

 Accepted Answer

Stephen23
Stephen23 on 28 Jan 2019
Edited: Stephen23 on 28 Jan 2019
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.

More Answers (0)

Categories

Asked:

on 28 Jan 2019

Commented:

on 28 Jan 2019

Community Treasure Hunt

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

Start Hunting!