- #1
muaaman
- 5
- 0
Homework Statement
uData is a 30x5 matrix with numbers. name_Database is a 30x1 cell array with strings of Names (e.g. Fake Subject 1, Fake Subject 2, Bob). What would fix the code so that the data aligns? (please see image for the misalignment).
Homework Equations
The Attempt at a Solution
[/B]
Code:
ID = dbedit.uData(:,1);
scE = dbedit.uData(:,2);
ccE = dbedit.uData(:,3);
scC = dbedit.uData(:,4);
ccC = dbedit.uData(:,5);
names = dbedit.name_Database;
% Text file to output data into is called uDatabase.txt file.
output_file = 'uDatabase.txt';
% Open file for writing
fid = fopen(output_file, 'w+');
% Header
fprintf(fid, '%6s %12s %18s %24s %30s %36s\n', 'Name', 'ID', 'scE',...
'ccE', 'scC', 'ccC');
% Write the data.
for ii=1:numel(names)
fprintf(fid, '%6s %12.0f %18.0f %24.0f %30.0f %36.0f\n',names{ii},...
ID(ii),scE(ii),ccE(ii),scC(ii),...
ccC(ii));
end
% Close the .txt file.
fclose(fid);