Audit the records written by fprintf

An engineer intends to export three measurements, with time in seconds in the first column and voltage in volts in the second column. The engineer runs this MATLAB code without rearranging the data:


MATLAB
data = [0.0 2.4;
        0.2 2.7;
        0.4 3.1];
fid = fopen('voltage_log.txt','wt');
fprintf(fid,'time_s,voltage_V\n');
fprintf(fid,'%.1f,%.1f\n',data);
fclose(fid);


Assume all file operations succeed. Determine what the file actually contains, even if its header assigns misleading meanings to the values.


Report the first numeric field of the second data record as a time in s, to one decimal place; report its second numeric field as a voltage in V, to one decimal place; and give the exact integer number of data records written. Exclude the header when numbering and counting data records.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Data Files and Character Strings Questions: