tryreadwritefile

tryreadwritefile - -2.5000 14.8000 36.0000 -7.7000 12.4000...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Page 1 of 2 tryreadwritefile.doc 3/5/2008 Read and then Rewrite a Matrix Using Files % tryreadwritefile.m clear; clc; % A row written 7 by 7 unsymmetical matrix is on file fid = fopen('umat.m','r'); disp('The data on the file is:'); type umat.m; [A,count] = fscanf(fid,'%f',[7,7]); % Must transpose data to get the row written matrix A = A'; disp('The matrix (after transpose) was input from file as:'); disp(A); disp('Value of count is: '); disp(count); fclose(fid); % Write the same matrix to a new file with different format fidw = fopen('newmat.m','w'); % Must transpose the matrix to get the matrix written by rows fprintf(fidw,' %6.1f %6.1f %6.1f %6.1f %6.1f %6.1f %6.1f\n',A'); fclose(fidw); disp('The newmat.m file:'); type newmat.m
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2 of 2 tryreadwritefile.doc 3/5/2008 The data on the file is: 12.0000 49.7000 51.3000 -28.4000 -68.2000 -19.8000 -87.9000 7.2000 31.0000 12.9000 -40.8000 70.4000 26.5000 -24.4000 -48.2000 -6.5000 1.4000 -82.0000 37.6000 -25.6000 59.4000 -85.3000
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: -2.5000 14.8000 36.0000 -7.7000 12.4000 -42.1000 -7.0000 -12.5000 -11.4000 -6.4000 -9.8000 10.7000 -19.5000 0.7000 -14.5000 42.0000 0.1000 38.2000 -38.8000 -73.1000 16.6000 71.7000 -17.0000 15.2000 17.9000 -14.9000 36.5000 The matrix (after transpose) was input from file as: 12.0000 49.7000 51.3000 -28.4000 -68.2000 -19.8000 -87.9000 7.2000 31.0000 12.9000 -40.8000 70.4000 26.5000 -24.4000 -48.2000 -6.5000 1.4000 -82.0000 37.6000 -25.6000 59.4000 -85.3000 -2.5000 14.8000 36.0000 -7.7000 12.4000 -42.1000 -7.0000 -12.5000 -11.4000 -6.4000 -9.8000 10.7000 -19.5000 0.7000 -14.5000 42.0000 0.1000 38.2000 -38.8000 -73.1000 16.6000 71.7000 -17.0000 15.2000 17.9000 -14.9000 36.5000 Value of count is: 49 The newmat.m file: 12.0 49.7 51.3 -28.4 -68.2 -19.8 -87.9 7.2 31.0 12.9 -40.8 70.4 26.5 -24.4 -48.2 -6.5 1.4 -82.0 37.6 -25.6 59.4 -85.3 -2.5 14.8 36.0 -7.7 12.4 -42.1 -7.0 -12.5 -11.4 -6.4 -9.8 10.7 -19.5 0.7 -14.5 42.0 0.1 38.2 -38.8 -73.1 16.6 71.7 -17.0 15.2 17.9 -14.9 36.5 >>...
View Full Document

This note was uploaded on 04/26/2010 for the course CEG 616 taught by Professor Taylor during the Winter '10 term at Wright State.

Page1 / 2

tryreadwritefile - -2.5000 14.8000 36.0000 -7.7000 12.4000...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online