Assignment 01
Assignment 01
Computer
Programming
Mechanical engineering department 3rd year (Power)
Assignment (1)
1- Complete the following sentences
a) Command ……………… is used to clear the variable in workspace
b) Command ………… is used to clear command window
c) Matlab is a ……………. level language
d) Variable names must start with a …………. followed by letters, digits,
and underscores.
e) It is not allowed to leave ……………………… in the name of the variable
f) Command ……… is used to clear Matlab figure.
g) The command ………………….. is used to determine the list of local
variables or commands presently in the workspace.
h) To run an M-flle, type the …………….. (without the extension) at the
command prompt (>>).
i) The name of user-defined variables should not duplicate the name of a
………………………. or Matlab command
2- What is the function of writing “%” at the beginning of a line in a Matlab
m-file.
3- How to connect two lines of a very long statement in Matlab?
4- Is the two following variable executed in Matlab are identical
>> a = 2;
>> A = 4 ;
5- If A=[1 2 ;3 4], what is the result of the following command, explain the
elements of the resulting matrix
>> C_A=[A, 2*A; 3*A, 4*A; 5*A, 6*A]
>> AB = A1*B
>> BA1 = B*A1
III) Term wise (element by element) multiplication
>> AA = A1.*A2
IV) Term wise multiplication A1(m, n) B(m, n)
>> A1B=A1.*B
V) >> Z = zeros(2,3), or zeros(size(A1)) , E=ones(3,2), F=diag(A1)