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

Ministry of education and science, youth and sport of Ukraine

National Aviation University

Computer Architecture

Laboratory work 5

MATLAB programming principles

Prepared by: Student of CSF - 205 Bashuk K.I.

Accepted by: Associate professor

Romanov E.I

Kyiv 2012

Table of contents

1.Task 7

2.Theory 7

Operators 7

Subfunctions 9

Private functions 9

Subscripting and Indexing 9

Subscripting 9

Indexing 9

String evaluation 10

Eval 10

Feval 10

Command/Function duality 10

Errors and Warnings 10

Dates and Times 11

Date formats 11

Current date and time 11

Obtaining user input 11

Prompting for keyboard input 11

Pausing during execution 12

Shell escape functions 12

Optimizing MATLAB code 12

3.Conclusion 12

  1. Task

1. Operators

2. Subfunctions

3. Private Functions

4. Subscripting and Indexing

• Subscripting

• Advanced Indexing

5. String Evaluation

• eval

• feval

6. Command/Function Duality

7. Errors and Warnings

8. Dates and Times

• Date Formats

• Current Date and Time

9. Obtaining User Input

• Prompting for Keyboard Input

• Pausing During Execution

10. Shell Escape Functions

11. Optimizing MATLAB Code

  1. Theory

Operators

Relational Operators

Relational operators compare operands quantitatively, using operators like "less than" and "not equal to." The following table provides a summary.

Table 1

Operator

Description

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to

==

Equal to

~=

Not equal to

Arithmetic Operators

Arithmetic operators perform numeric computations, for example, adding two numbers or raising the elements of an array to a given power. The following table provides a summary.

Table 2

Operator

Description

+

Addition

-

Subtraction

.*

Multiplication

./

Right division

.\

Left division

+

Unary plus

-

Unary minus

:

Colon operator

.^

Power

.'

Transpose

'

Complex conjugate transpose

*

Matrix multiplication

/

Matrix right division

\

Matrix left division

^

Matrix power

Logical Operators

MATLAB offers three types of logical operators and functions:

  • Element-wise - operate on corresponding elements of logical arrays (tab. 3).

  • Short-circuit - operate on scalar, logical expressions (tab. 4).

Table 3

Operator

Description

Example

&

Returns 1 for every element location that is true (nonzero) in both arrays, and 0 for all other elements.

A & B = 01001

|

Returns 1 for every element location that is true (nonzero) in either one or the other, or both arrays, and 0 for all other elements.

A | B = 11101

~

Complements each element of the input array, A.

~A = 10010

xor

Returns 1 for every element location that is true (nonzero) in only one array, and 0 for all other elements.

xor(A,B) = 10100

Table 4

Operator

Description

&&

Returns logical 1 (true) if both inputs evaluate to true, and logical 0 (false) if they do not.

||

Returns logical 1 (true) if either input, or both, evaluate to true, and logical 0 (false) if they do not.

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