So I wrote some code and need to output my variables, that are in a cell array, to a csv file. The code below shows how I attempt to do it, but I get the error of, "function is not defined for 'cell' inputs."
fid = fopen('Masonry.csv', 'w');
for n = 1:numel(numberRows)
fprintf(fid, '%s', NameofTypeMasonry(n));
fprintf(fid, '%s', CountryofTypeMasonry(n));
fprintf(fid, '%s', CityofTypeMasonry(n));
fprintf(fid, '%d', HeightofTypeMasonry(n));
end
does anyone have any idea how to fix this?

 Accepted Answer

Stephen23
Stephen23 on 22 Mar 2017
Edited: Stephen23 on 22 Mar 2017
Possibly you just need to use cell array indexing:
fid = fopen('Masonry.csv', 'wt');
for n = 1:numel(numberRows)
fprintf(fid, '%s', NameofTypeMasonry{n});
fprintf(fid, '%s', CountryofTypeMasonry{n});
fprintf(fid, '%s', CityofTypeMasonry{n});
fprintf(fid, '%d', HeightofTypeMasonry{n});
end
fclose(fid)

1 Comment

everything worked expect for "HeightofTypeMasonry" i had to use regular parenthesis.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!