MATLAB: Unable to convert expression into double array

MATLABunable to convert expression into double array. wrong.

Dear all
In the code I would like to use sym function to calculate this function.But I keep getting this error.
"Unable to convert expression into double array.'
I=zeros(256,256);
syms t;
for i=1:256
for j=1:256
I(i,j)=1+cos(2*pi*(19.5+t)*i/1950/10^-4)-cos(2*pi*100*i);
end
end

Best Answer

You are initializing I as double matrix, initialize it as a symbolic matrix
syms t;
I = zeros(256,256, 'like', t);
for i=1:256
for j=1:256
I(i,j)=1+cos(2*pi*(19.5+t)*i/1950/10^-4)-cos(2*pi*100*i);
end
end