0% found this document useful (0 votes)
7 views6 pages

CAE Assignment Miss Noreen

Uploaded by

Muneeb K.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

CAE Assignment Miss Noreen

Uploaded by

Muneeb K.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Assignment #1

NAME: MUNEEB UR REHMAN

ROLL NO: IM – 23069

DEPARTMENT: INDUSTRIAL AND

MANUFACTURING

COURSE CODE: CAE – 101

SECTION: (B)
Q1-Write down the details of Statistical functions used in matlab with
example.
1. mean() - Mean (Average)
 Syntax: mean(X)
 Returns the mean (average) value of the elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
mean_value = mean(X)
Output: mean_value = 3

2. median() - Median
 Syntax: median(X)
 Returns the median value of the elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
median_value = median(X)
Output: median_value = 3

3. mode() - Mode (Most Frequent Value)


 Syntax: mode(X)
 Returns the most frequent value in the array X.
 Example: X = [1, 2, 2, 3, 3, 3];
mode_value = mode(X)
Output: mode_value = 3
4. std() - Standard Deviation
 Syntax: std(X)
 Returns the standard deviation of the elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
Std_dev = std(X)
Output: std_dev = 1.5811
5. var() - Variance
 Syntax: var(X)
 Returns the variance of the elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
variance = var(X)
Output: variance = 2.5000

Q2- Write down the details of Data manipulation functions used in matlab
with example.
1. max() - Returns the maximum value
 Syntax: max(X) or max(X, [], dim)
 Returns the maximum value in the array X.
 Example: X = [1, 2, 3, 4, 5];
max_value = max(X)
Output: max_value = 5
2. min() - Returns the minimum value
 Syntax: min(X) or min(X, [], dim)
 Returns the minimum value in the array X.
 Example: X = [1, 2, 3, 4, 5];
min_value = min(X)
Output: min_value = 1
3. sum() - Returns the sum of elements
 Syntax: sum(X) or sum(X, dim)
 Returns the sum of all elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
sum_X = sum(X)
Output: sum_X = 15
4. prod() - Returns the product of elements
 Syntax: prod(X) or prod(X, dim)
 Returns the product of all elements in the array X.
 Example: X = [1, 2, 3, 4, 5];
prod_X = prod(X)
Output: prod_X = 120
5. sort() - Sorts elements in ascending order
 Syntax: sort(X) or sort(X, dim)
 Returns a sorted version of the array X.
 Example: X = [3, 1, 4, 1, 5];
sorted_X = sort(X)
Output: sorted_X = [1, 1, 3, 4, 5]

Q3- Write down the details of Mathematical Functions used in matlab with
example.

1. abs() - Absolute value


 Syntax: abs(X)
 Returns the absolute value (magnitude) of the elements in X.
 Example: X = [-3, 2, -1, 4];
abs_X = abs(X)
Output: abs_X = [3, 2, 1, 4]
2. sqrt() - Square root
 Syntax: sqrt(X)
 Returns the square root of the elements in X.
 Example: X = [9, 16, 25];
sqrt_X = sqrt(X)
Output: sqrt_X = [3, 4, 5]
3. log() - Natural logarithm
 Syntax: log(X)
 Returns the natural logarithm (base e) of the elements in X.
 Example: X = [1, 2, 3];
log_X = log(X)
Output: log_X = [0, 0.6931, 1.0986]
4. exp() - Exponential
 Syntax: exp(X)
 Returns the exponential (base e) of the elements in X.
 Example: X = [1, 2, 3];
exp_X = exp(X)
Output: exp_X = [2.7183, 7.3891, 20.0855]
5. sin(), cos(), tan() - Trigonometric functions
 Syntax: sin(X), cos(X), tan(X)
 Returns the sine, cosine, and tangent of the elements in X (in radians).
 Example: X = [pi/4, pi/2, pi];
sin_X = sin(X);
cos_X = cos(X);
tan_X = tan(X)
Output: sin_X = [0.7071, 1, 0], cos_X = [0.7071, 0, -1], tan_X = [1, Inf, 0]

Q4-Rounding and remainder functions used in matlab with example.

Round()
x = 3.7;
y = round(x); % y = 4

Floor()
x = 3.7;
y = floor(x); % y = 3

Ceil()
x = 3.7;
y = ceil(x); % y = 4

Mod()
x = 17;
y = 5;
z = mod(x, y); % z = 2
In this example, mod(17, 5) returns the remainder of dividing 17 by 5, which is 2.
Rem()
x = 17;
y = 5;
z = rem(x, y); % z = 2
In this example, rem(17, 5) returns the remainder after dividing 17 by 5, which is 2.

You might also like