0% found this document useful (0 votes)
65 views4 pages

Assignment #1 (Learn MATLAB) : COMSATS Institute of Information Technology (CIIT)

This document provides examples of 10 basic MATLAB commands - addition, display, concatenation, products, sorting, reshaping, cross product, dot product, rank, and reduced row echelon form - listing the command syntax and examples of usage for each one to perform common mathematical operations on arrays and matrices in MATLAB.

Uploaded by

Muhammad Usman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views4 pages

Assignment #1 (Learn MATLAB) : COMSATS Institute of Information Technology (CIIT)

This document provides examples of 10 basic MATLAB commands - addition, display, concatenation, products, sorting, reshaping, cross product, dot product, rank, and reduced row echelon form - listing the command syntax and examples of usage for each one to perform common mathematical operations on arrays and matrices in MATLAB.

Uploaded by

Muhammad Usman
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

COMSATS Institute of Information

Technology (CIIT)
Islamabad Campus

Assignment #1
(Learn MATLAB)

Name: Muhammad Usman


Registration No.: FA07-BSM-021
Subject: Calculus of Variation
Teacher: Dr.Shams-ul-Islam
Few Basic Commands of MATLAB
S.No# Comma Description Syntax Example
nds
1. + Addition or Binary addition a = [1 2 3];
unary plus. A+B A+B:
adds A and B. A plus(A,B) & b = [4 5 6];
and B must Unary plus: +A
have the same uplus(A) plus(A,B)
size, unless one &
is a scalar. A uplus(A)
scalar can be
added to a
matrix of any
size.
2. Loose Display extra theta = pi/2
line feeds for a
more readable theta=
display.
1.5708
3. Cat Concatenates C = cat (dim, A = magic(3); B =
all the input A1, A2, A3, pascal(3);
arrays (A1, A2, A4...)
A3, A4, and so C = cat(4,A,B);
on) along dim. produce a 3-by-3-
by-1-by-2 array.
4. Prod The products B = prod(A) M = magic(3);
along different
dimensions of prod(M);
an array. If A is
a vector,
prod(A) returns
the product of
the elements. If
A is a matrix,
prod(A) treats
the columns of
A as vectors,
returning a row
vector of the
products of
each column.

5. Sort sorts the B = sort(A) A = [ 3 7 5;0 4


elements along 2 ];
different
dimensions of B = sort(A);
an array, and
arranges those
elements in
ascending
order. If A is
a ...sort(A)
...VectorSorts
the elements of
A in ascending
order.MatrixSort
s each column
of A in
ascending
order.
6. Reshape the m-by-n B= A = magic(3);
matrix B whose reshape(A,m,n) B=
elements are reshape(A,1,9);
taken column-
wise from A. an
N-D array with
the same
elements as A
but reshaped to
have the size
m-by-n-by-p-
by-... . The
product of the
specified
dimensions,
m*n*p*..., must
be the same as
prod(size(A)).
7. Cross the cross C = cross(A,B) a = [1 2 3];
product of the
vectors A and B b = [4 5 6];

c = cross(a,b)

8. Dot the scalar C = dot(A,B) a = [1 2 3]; b =


product of the [4 5 6];
vectors A and B.
c = dot(a,b)

9. Rank The rank k = rank(A) A = [1 2 1;2 4 2;1


function 1 1];
provides an k=rank(A);
estimate of the
number of
linearly
independent
rows or columns
of a full matrix.
10. Rref produces the R = rref(A) A = magic(4);
reduced row R = rref(A);
echelon form of
A using Gauss
Jordan
elimination with
partial pivoting.

You might also like