I am trying to use eval to assign a cellValue to a field in a struct. The struct has been pre-initialized. I am getting a horzcat error that I can’t remove. Can you please help me out here. Also, I know using eval is not recommended. Can you suggest a better alternative to it that can be used here. cellValue is a big cell with almost 200,000 rows and this step would be run repeatedly. So vectorization and efficiency is needed. Thanks!
varA = struct('Raw', -1, 'ttm', -1, 'USD', -1) ;
cellValue = { 'AAPL' [10010] 'abc' ;
'AAPL' [10020] 'abc' ;
'AAPL' [10030] 'abc' } ;
eval([varA '.Raw = ' cellValue ]) %gives horzcat ERROR
% Desired result from varA.Raw = cellValue
varA =
Raw: {3x3 cell}
ttm: -1
USD: -1
well this works: