I have a matrix 'F' (3 * 20 double) and a cell-type 'ans' (20*1) consisting of variables of the form (1,x,y,z,xy,yx,...). I wanted to multiply F and ans to get a system of equations and use that to get the function
f = @(t,y) F * ans
which I will later use to solve ODEs. This gives me the error
Operator '*' is not supported for operands of type 'cell'.
Now, I am unable to convert celltype to type double. If I write
var = str2double(ans)
then var is simply consisting of NaN instead of the variables. Can someone please help?
ansas a variable name. It is the default output variable if no other is specified. This is almost guaranteed to create problems. Save it as something else.cellis not a string. Cells are "containers" that can store whatever information you want, numbers, strings, structs, cells or even function handles.If your cell contains numeric values, then you must convert it to a numeric matrix. There are many ways to do this, but the most intuitive way is simply using
cell2mat.This will only work if each of your cells contain the same number of columns, and all cells contain only numeric data.