Professional Documents
Culture Documents
Complex Argument: To Show How The Functions of Work For Imaginary or Complex Variables, Consider The Following Examples
Complex Argument: To Show How The Functions of Work For Imaginary or Complex Variables, Consider The Following Examples
» a = log(x)
a=
0.4581 + 0.3218 i
» b = exp(a)
b=
1.5000 + 0.5000i
Array argument
Most functions in MATLAB can take vectors
and matrices as argument. For example,
» x = [pi/2 , 0 , pi/4 ; pi/6 , -pi/4 , pi/3 ]
x=
1.5708 0 0.7854
0.5236 -0.7854 1.0472
» y = sin(x)
y=
1.0000 0 0.7071
0.5000 -0.7071 0.8660
Developing a program as an m-file
Executing commands from a window is suitable
only if the amount of typing is small, or if we
want to explore ideas interactively.
When commands are more than few lines long,
or the user should write a script m-file, or a
function m-file, because they are saved to disk
and can be corrected as many times as required.
The m-file can include anything the user would
write directly in the command window.
While function m-file corresponds to sub-
program, subroutine, or function in traditional
languages. A useful feature of m-files is that,
an m-file can call other m-files.
corresponding to x = 1.
* We start first by opening a new m-file
* We save this file as , for example, fraction.m
* We then write and save the script
* The script is shown in the figure below
* Notice that the name of the m-file is identical
to the name of the function, which appears
on the right hand side of the equality sign.
* In the m-file the array arithmetic operators
are used, so the argument can be a scalar
as well as a vector or a matrix.