BigChief
BigChief

Reputation: 1515

Matlab Error: Function is not defined for 'cell' inputs

fid = fopen('./tickers.tex', 'wt+');
for x = 1 : size(C.names,1) 
    fprintf(fid, '%s & ', C.names(x,1:end-1)); 
    fprintf(fid, '%s \\\\ \t\n', C.names(x,end)); 
end 
fclose(fid);

Why does this give me the error:

Error using fprintf Function is not defined for 'cell' inputs.

While this does work:

fprintf(' %f    ', D{:});

I'm having difficulties understanding basic matlab datatypes. Could anyone provide me with a solution to print the cell array just like the last syntax?

Upvotes: 2

Views: 8597

Answers (1)

ASantosRibeiro
ASantosRibeiro

Reputation: 1257

Ok from the error and code you have I am assuming C is an array of cells and you want to print some string from each entry of C. Assuming this, your code is incorrect. Try this:

fid = fopen('./tickers.tex', 'wt+');
for x = 1 : size(C,1) 
    fprintf(fid, '%s & ', C{x}.names(1:end-1)); 
    fprintf(fid, '%s \\\\ \t\n', C{x}.names(end)); 
end 
fclose(fid);

Is this what you want? If not please provide more information about C

Upvotes: 1

Related Questions