myCSVwrite - %purely numeric array. function myCSVwrite(A,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %Write a function called myCSVwrite which takes in a cell array of doubles %and chars and a filename, returns nothing but writes a file with each of the cells' %contents seperated by commas. The cell array may be two dimensional, you %should put each row of the cell array in a different line in the file %sequentially. %Notice, unlike csvwrite, your function takes in a cell array instead of a
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %purely numeric array. function myCSVwrite(A, filename) [rows, cols] = size(A) fid = fopen(filename, 'w') for x = 1:rows z = '' for y = 1:cols C = A{x, y} if isnumeric(C) C = num2str(C) elseif isempty(C) C = '' end if y < cols z = [z, C, ','] else z = [z, C] end end fprintf(fid, '%s\n', z) end fclose(fid)...
View Full Document

This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online