I have a cell array of character vectors:
>> listlist = 5×1 cell array {'10^{-4}'} {'10^{-3}'} {'10^{-2}'} {'10^{-1}'} {'10^{0}' }
I want to convert these vectors into the numbers they represent. I tried to use str2num, but it doesn't work with arrays or cell arrays. Using str2double, I get a cell array of NaNs because the character vectors are not only numbers, but rather expressions to evaluate. So I tried to use eval. This is my first attempt:
>> eval(list)Error using evalMust be a string scalar or character vector.
So I thought using cellfun would do the job because eval would be fed only one vector at a time, but instead I get this:
>> cellfun(eval, list)Error using evalNot enough input arguments.
After further tests, it seems like eval doesn't work with cellfun or arrayfun, which doesn't make sense to me. Is there any way to convert my expressions into numbers?
Best Answer