Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Bashuk Kirill / lab4_arch.docx
Скачиваний:
7
Добавлен:
20.02.2016
Размер:
864.07 Кб
Скачать

Ministry of education and science, youth and sport of Ukraine

National Aviation University

Computer Science Faculty

Department of Software Engineering

Computer Architecture

Laboratory work 4

MATLAB programming principles

Prepared by: Student of CSF-205

Bashuk Kirill

Accepted by: Associate Professor

Romanov E.I.

Kyiv 2012

Content

MatLAB programming 7

Kinds of M-files 7

M-file structure 7

Providing help for programs 7

Creating M-Files: Accessing Text Editors 7

Scripts: 7

Simple Script Example 8

Functions 8

Simple functions example 8

Basic parts of a function M-file 9

Function names 9

How functions work 9

Checking the number of function arguments 9

Passing variable numbers of arguments 10

Local and Global variables 10

Persistent Variables 10

Special Values 10

Data Types 11

Keywords 11

Flow Control 12

Conclusion 14

References 15

Lab_4 CA_Sec.pdf . Romanov E.I. 1p. 15

Lec_4_CA_engl.pdf . Romanov E.I. 5p. 15

Help of MatLab R2012a (7.14.0.739). The MathWorks Inc. 1984-2012 15

Task

  1. MATLAB Programming:

Kinds of M-Files.

  1. M-File Structure.

  2. Providing Help for Programs.

  3. Creating M-Files: Accessing Text Editors

  4. Scripts:

Simple Script Example.

  1. Functions:

Simple Function Example;

Basic Parts of a Function M-File;

Function Names;

How Functions Work;

Checking the Number of Function Arguments;

Passing Variable Numbers of Arguments.

  1. Local and Global Variables:

Persistent Variables;

Special Values.

  1. Data Types.

  2. Keywords

  3. Flow Control

Theory MatLab programming Kinds of m-files

Scripts M-files

Functions M-files

M-file structure

Elements that are common to all MATLAB functions:

A function definition line . This line defines the function name, and the number and order of input and output arguments.

An H1 line. H1 stands for “help 1” line. MATLAB displays the H1 line for a function when you use lookfor or request help on an entire directory.

Help text. MATLAB displays the help text entry together with the H1 line when you request help on a specific function.

The function body. This part of the function contains code that performs the actual computations and assigns values to any output arguments.

Providing help for programs

You can provide user information for the programs you write by including a help text section at the beginning of your M-file. This section starts on the line following the function definition and ends at the first blank line. Each line of the help text must begin with a comment (% ) character. MATLAB displays this information whenever you type help m-file_name.

You can also make help entries for an entire directory by creating a file with the special name Contents.m that resides in the directory. This file must contain only comment lines; that is, every line must begin with a percent sign. MATLAB displays the lines in a Contents.m file whenever you type help directory_name.

If a directory does not contain a Contents.m file, typing help directory_name displays the first help line (the H1 line) for each M-file in the directory.

Соседние файлы в папке Bashuk Kirill