Sie sind auf Seite 1von 17

Load

Load workspace variables from disk

Syntax

Save
Save workspace variables on disk Graphical Interface As an alternative to the save function, select Save Workspace As from the File menu in the MATLAB desktop, or use the Workspace browser.

Syntax

Open
Open files based on extension

Syntax

Description open('name') opens the object specified by the string name. The specific action taken upon opening depends on the type of object specified by name.

Eng \ Hadeer Sobhy

Opening a MAT-File

Eng \ Hadeer Sobhy


2

Fopen
Open a file or obtain information about open files

Syntax

Description

- fid = fopen(filename) opens the file filename for read access. (On PCs, fopen
opens files for binary read access.) - fid is a scalar MATLAB integer, called a file identifier. You use the fid as the first argument to other file input/output routines. If fopen cannot open the file, it returns -1. - fid = fopen(filename, mode) opens the file filename in the specified mode. The mode argument can be any of the following:

Fclose
Close one or more open files

Syntax

Description

- status = fclose(fid) closes the specified file if it is open, returning 0 if successful


and -1 if unsuccessful.

Eng \ Hadeer Sobhy


3

Argument fid is a file identifier associated with an open file. (See fopen for a complete description of fid). If fid does not represent an open file, or if it is equal to 0, 1, or 2, then fclose throws an error. - status = fclose('all') closes all open files (except standard input, output, and error), returning 0 if successful and -1 if unsuccessful.

Fprintf
Write formatted data to file

Syntax
Description

- count = fprintf(fid,format,A,...) formats the data in the real part of matrix A


(and in any additional matrix arguments) under control of the specified format string, and writes it to the file associated with file identifier fid. fprintf returns a count of the number of bytes written.

Eng \ Hadeer Sobhy


4

This table lists the escape character sequences you use to specify nonprinting characters in a format specification.

Fread
Read binary data from file

Syntax

Description

- A = fread(fid) reads data in binary format from the file specified by fid into
matrix A. - Open the file using fopen before calling fread. The fid argument is the integer file identifier obtained from the fopen operation. - MATLAB reads the file from beginning to end, and then positions the file pointer at the end of the file.

Eng \ Hadeer Sobhy


5

Specifying Precision
Any of the strings in the following table, either the MATLAB version or their C or FORTRAN equivalent, can be used for precision. If precision is not specified, MATLAB uses the default, which is 'uchar'.

The following platform-dependent formats are also supported, but they are not guaranteed to be the same size on all platforms.

Eng \ Hadeer Sobhy


6

Examples:
Example 1 The file alphabet.txt contains the 26 letters of the English alphabet, all capitalized. Open the file for read access with fopen, and read the first five elements into output c. Because a precision has not been specified, MATLAB uses the default precision of uchar, and the output is numeric:

This time, specify that you want each element read as an unsigned 8-bit integer and output as a character. (Using a precision of 'char=>char' or '*char' will produce the same result):

When you leave out the optional count argument, MATLAB reads the file to the end, A through Z:

The fopen function positions the file pointer at the start of the file. So the first fread in this example reads the first five elements in the file, and then repositions the file pointer at the beginning of the next element. For this reason, the next fread picks up where the previous fread left off, at the character

Eng Eng \ Hadeer Sobhy


7

Skip two elements between each read by specifying a skip argument of 2:

Fwrite
Write binary data to a file

Syntax

Description

- count = fwrite(fid,A,precision) writes the elements of matrix A to the specified


file, translating MATLAB values to the specified precision. - The data is written to the file in column order, and a count is kept of the number of elements written successfully.

Examples:

Eng \ Hadeer Sobhy


8

Programs:
Reading and Writing wave files

Reading and Writing text files

Eng \ Hadeer Sobhy


9

To open SIMULINK at MATLAB

Then ..

Eng \ Hadeer Sobhy

10

OR .

Then ..

Eng \ Hadeer Sobhy


11

SIMULINK

Signal Processing Blackest

Eng \ Hadeer Sobhy


12

Now lets try something a little bit more complicated. First, build the following system (you can find the Clock module in the Sinks category. The Trigonometric Function and Sum modules reside in the Math category):

Output on Time Scope

Now, lets see if the derivative is really a cosine. Build the following system (the Derivative module is located in the Continuous category):

Eng \ Hadeer Sobhy


13

We can see that this is indeed a cosine, but something is wrong at the beginning.

Eng \ Hadeer Sobhy


14

1. Low Pass Filter 2. High Pass Filter 3. Band Pass Filter 4. Band Stop Filter 5. Resonator Filter 6. Notch Filter Eng \ Hadeer Sobhy
15

Low Pass Filter

High Pass Filter

Band Pass Filter

Notch Filter

To get filter on simulink as follow: Signal Processing Blackest >>Filtering>>Filter Design>>Digital Filter Design

Eng \ Hadeer Sobhy


16

Eng \ Hadeer Sobhy


17

Das könnte Ihnen auch gefallen