How do I open a new file for writing?

4 次查看(过去 30 天)
I've already created the code needed for this part:
%Part A
clear all; clc;
tempdata = fopen('rec0506a.dat','r') ;
fgetl(tempdata);
fgetl(tempdata);
T = fscanf(tempdata, '%*f%f%f%f ',[3,inf])';
fclose(tempdata);
%Part B (means)
clc;
format shortg
sensormean= mean(T) ;
hourlymean = mean(T')' ;
%Part C (Table)
clc;
overallmean = (mean(sensormean) + mean(hourlymean))./2;
t = 1:8;
fprintf('hour T1 T2 T3 | means \n------------------------------------------------- \n')
fprintf('%2d %5d %4d %1d | %4.1f \n',[t',T,hourlymean]')
fprintf('--------------------------------------------------- \n')
fprintf('means = %2.1f %8.1f %7.1f | %6.1f \n',[sensormean,overallmean]')
How exactly do I do this part though? It's confusing me.
D) Open a new file for writing, say rec0506b.dat. Using again at most five fprintf commands, save the above table of Part (c) in the new file, then close the file and upload it on sakai together with the rest of your recitation work.

采纳的回答

Gareth Thomas
Gareth Thomas 2015-10-25
See: fopen
try using: fopen with 'w' instead of 'r'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by