Umal-qura university



Yüklə 0,73 Mb.
səhifə9/30
tarix23.12.2023
ölçüsü0,73 Mb.
#156716
1   ...   5   6   7   8   9   10   11   12   ...   30
Signal and Systems Manual - v2full

Script Vs Function




  1. A script is simply a collection of Matlab commands in an m‐file. Upon typing the name of the file (without the extension), those commands are executed as if they had been entered at the keyboard.

Functions are used to create user‐defined matlab commands.



  1. A script can have any name.

A function file is stored with the name specified after keyword function.



  1. The commands in the script can refer to the variables already defined in Matlab, which are said to be in the global workspace.

When a function is invoked, Matlab creates a local workspace. The commands in the function cannot refer to variables from the global (interactive) workspace unless they are passed as inputs. By the same token, variables created as the function executes are erased when the execution of the function ends, unless they are passed back as outputs.


-------------------------TASK 01--------------------------
Write a function that accepts temperature in degrees F and computes the corresponding value in degrees C. The relation between the two is


TC = 5/9 * (TF - 32)



    1. CONTROL STRUCTURES

Control‐of‐flow in MATLAB programs is achieved with logical/relational constructs, branching constructs, and a variety of looping constructs.





      1. Relational and logical constructs

The relational operators in MATLAB are


Operator Description
===================================
< less than
> greater than
<= less than or equal
>= greater than or equal
== equal
~= not equal

Yüklə 0,73 Mb.

Dostları ilə paylaş:
1   ...   5   6   7   8   9   10   11   12   ...   30




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə