I'm trying to write something like the following to file.
keys = {'one','two','three'}
values = [1 2 3]
This is my code so far:
function save_recording_results(keys,values)
keys=keys.';
fid = fopen('hoping', 'wt');
fprintf(fid, '%s : %f\n', keys{:},values);
fclose(fid);
end
My output is this:
one : 116.000000
wo : 116.000000
hree : 1.000000
:
I want it to look like this:
one : 1
two : 2
three : 3
I'm not sure what I'm doing wrong. Why does it drop the first character? This happens even when the first character isn't 't'. I gather that what it is doing is printing the first letter of the (n+1)th variable on the line for the nth variable after the colon. (T is 116 in ASCII.) But, why?