How do I open a new file for writing?

4 ビュー (過去 30 日間)
Ruten9
Ruten9 2015 年 10 月 25 日
編集済み: per isakson 2015 年 11 月 10 日
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'
  1 件のコメント
Ruten9
Ruten9 2015 年 10 月 25 日
I figured that already. Thanks though!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by