Umal-qura university



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

Variable Assignment

The equality sign is used to assign values to variables:
>> x = 3
x =
3
>> y = x^2
y =
9
Variables in MATLAB are case sensitive. Hence, the variables "x" and "y" are distinct from "X" and "Y" (at this point, the latter are in fact, undefined).
Output can be suppressed by appending a semicolon to the command lines.
>> x = 3;
>> y = x^2;
>> y
y =
9

      1. Active Variables

At any time you want to know the active variables you can use who:


>> who Your variables are: ans x y



      1. Removing a Variable

To remove a variable, try


this: >> clear x
To remove all the variables from workspace, use clear >> clear



      1. Saving and Restoring Variables

To save the value of the variable "x" to a plain text file named "x.value"


use >> save x.value x ‐ascii
To save all variables in a file named mysession.mat, in reloadable format, use
>> save mysession To restore the session, use
>> load mysession
    1. VARIABLE ARITHMETIC

MATLAB uses some fairly standard notation. More than one command may be entered on a single line, if they are separated by commas.


>> 2+3;
>> 3*4, 4^2;
Powers are performed before division and multiplication, which are done before subtraction and addition. For example
>> 2+3*4^2;
generates ans = 50. That is:
2+3*4^2 ==> 2 + 3*4^2 <== exponent has the highest precedence ==> 2 + 3*16 <== then multiplication operator
==> 2 + 48 <== then addition operator
==> 50




      1. Yüklə 0,73 Mb.

        Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   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ə