error in creating .coe file

1 view (last 30 days)
debalina ghosh
debalina ghosh on 28 Nov 2011
clear all;
size = 255;
N = 0 : size;
B = 10;
div = (N-1) ./ (N+1);
c = atanh(div);
filename = 'catanh_coeff.coe';
fid = fopen(filename,'wt');
fprintf(fid,'memory_initialization_radix=10;\n');
fprintf(fid,'memory_initialization_vector=\n');
i=0:size;
fprintf(fid,'%d,\n', c(i)); <-------------error
fprintf(fid,'%d;\n', c(size));
fclose(fid);
error : ??? Subscript indices must either be real positive integers or logicals.
Error in ==> atan_coeff at 12 fprintf(fid,'%d,\n', c(i));

Accepted Answer

Walter Roberson
Walter Roberson on 28 Nov 2011
Your line
i=0:size;
sets i to be a vector of values starting with 0. You then try to index by i, but indexing at 0 is not permitted.
I suggest you remove the "i=" line, and change the line after it to
printf(fid,'%d,', c(1:end-1));

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!