Академический Документы
Профессиональный Документы
Культура Документы
Department of Physics
ID No: WOUR/2818/10
1
1. i. What Is MATLAB? Answer -: The name MATLAB stands for matrix laboratory. MATLAB
is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions
are expressed in familiar mathematical notation.
ii. What are some of the uses of Mat Lab programming? Answer
Math and computation
Algorithm development
Modeling, simulation, and prototyping
Data analysis, exploration, and visualization
Scientific and engineering graphics
Application development, including Graphical User Interface building
2
Interpolation, extrapolation, and regression
Differentiation and integration
Linear systems of equations
Eigenvalues and singular values
Ordinary differential equations (ODEs)
Partial differential equations (PDEs)
4. i. What is M-file of MatLab? An m-file, or script file, is a simple text file where you can
place MATLAB commands. When the file is run, MATLAB reads the commands and
executes them exactly as it would if you had typed each command sequentially at the
MATLAB prompt. All m-file names must end with the extension '.
ii. Why we need M-files for? Because M-Files provides Intelligent Information
Management solutions for all document management.
iii. What is the difference between using command window to using M-file for a given
task?
You cannot define a function in the command window.
You cannot run () the command window.
You cannot use the graphical debugging tools well in the command window.
Error tracebacks are poor in the command window.
You cannot use mfilename in the command window .
You cannot pause execution in the command window .
In r2016b and later you can define scripts in script files.
you can run() a script
Debugging is better with script files
mfilename has some uses in a script
5. i. What is a script? Answer
Scripts − script files are program files with .m extension. In these files, you write series of
commands, which you want to execute together.
ii. What are the properties of a script file? Answer
Script properties are added to a script component by defining them with the go. Property
() special function. The function has to be used at the top level—outside any callback-
3
functions like init () and update (). The default value provided for the property governs the
type of the script property:
-number,
- hash,
-boolean,
-msg.url,
-vmath.vector3,
-vmath.vector4,
- vmath.quaternion and resource
6. i. What is function? Answer
Functions − functions files are also program files with .m extension that can accept
inputs and return outputs.
ii. What are the properties of a function file? Answer
A MATLAB file of a special format that contains code with optional properties
-inputs and
-outputs
Some advantages:
Functions can be called from inside of other script and function M-files.
Inputs allow variable values to be modified when calling the function (eg from
the Command Window).
Outputs can be assigned to other variables at the Command Window or within a
separate M-file.
Disadvantages:
A slight disadvantage with a function M-file is that you must follow the prescribed
format, or else it won’t run correctly. Once you get the hang of that, you will see they
are often very useful.
7. What are the difference between scripts and functions? Answer
i. Scripts − script files are program files with .m extension. In these files, you write
series of commands, which you want to execute together. Scripts do not accept
inputs and do not return any outputs. They operate on data in the workspace.
ii. Functions − functions files are also program files with .m extension. Functions
can accept inputs and return outputs. Internal variables are local to the function.