Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

fileread

Read contents of file as text

Syntax

text = fileread(filename)

Description

text = fileread(filename) returns a character vector that contains the contents of the file specified by filename. Specify filename as a character vector.

Examples

Read and search the file Contents.m in the MATLAB® iofun directory for the reference to fileread:

% find the correct directory and file
io_contents = ...
  fullfile(matlabroot,'toolbox','matlab','iofun','Contents.m');

% read the file
filetext = fileread(io_contents);

% search for the line of code that includes 'fileread'
% each line is separated by a newline ('\n')

expr = '[^\n]*fileread[^\n]*';
fileread_info = regexp(filetext,expr,'match');
Was this topic helpful?