function cell2csv( filename, cell_array )

fid = fopen(filename, 'w') ;

[nrows,ncols] = size(cell_array);
for r=1:nrows
    for c=1:ncols
        val = cell_array{r,c};
        if(ischar(val))
            chr = val;
        else
            chr = num2str(val);
        end
        if(c < ncols)
            fprintf(fid, '%s,', chr);
        else
            fprintf(fid, '%s\n', chr);
        end
    end
end

fclose(fid);
end

