MATLAB Lab Exercises: Matrix Operations, Geometric Series, and Function Evaluation, Schemes and Mind Maps of Mathematics

This lab exercise provides a comprehensive introduction to fundamental matlab operations, including matrix manipulation, geometric series computation, and function evaluation. It guides students through a series of exercises that demonstrate key concepts and techniques in matlab programming. The exercises cover matrix multiplication, concatenation, solving linear equations, and implementing functions for geometric series calculations. Students will gain practical experience in using matlab for numerical computations and data analysis.

Typology: Schemes and Mind Maps

2024/2025

Uploaded on 03/08/2025

kartik-bhangal
kartik-bhangal 🇺🇸

2 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LAB 2 - Kartik Bhangal - MAT 275
Exercise 1
Part (a)
A = [-9 6 -9; 5 -2 -9; -3 -2 -8];
B = [8 16 -4; -3 19 -3; 16 5 6];
b = [26; 1; 8];
c = [2 5 -2];
d = [3; 2; 0];
AB = A * B;
BA = B * A;
cA = c * A;
Bd = B * d;
Part (b)
C = [A; B];
D = [B d];
disp('C ='); disp(C);
C =
-9 6 -9
5 -2 -9
-3 -2 -8
8 16 -4
-3 19 -3
16 5 6
disp('D ='); disp(D);
D =
8 16 -4 3
-3 19 -3 2
16 5 6 0
Part (c)
pf3
pf4
pf5

Partial preview of the text

Download MATLAB Lab Exercises: Matrix Operations, Geometric Series, and Function Evaluation and more Schemes and Mind Maps Mathematics in PDF only on Docsity!

LAB 2 - Kartik Bhangal - MAT 275

Exercise 1

Part (a)

A = [-9 6 -9; 5 -2 -9; -3 -2 -8];

B = [8 16 -4; -3 19 -3; 16 5 6];

b = [26; 1; 8]; c = [2 5 -2]; d = [3; 2; 0]; AB = A * B; BA = B * A; cA = c * A; Bd = B * d;

Part (b)

C = [A; B];

D = [B d]; disp('C ='); disp(C); C = -9 6 - 5 -2 - -3 -2 - 8 16 - -3 19 - 16 5 6 disp('D ='); disp(D); D = 8 16 -4 3 -3 19 -3 2 16 5 6 0

Part (c)

x = A \ b; disp('x ='); disp(x); x = -0.

-0.

Part (d)

A(3, 3) = 0;

disp('Modified A ='); disp(A); Modified A = -9 6 - 5 -2 - -3 -2 0

Part (e)

a = A(2, :); disp('a ='); disp(a); a = 5 -2 -

Part (f)

B(:, 3) = [];

disp('Modified B ='); disp(B); Modified B = 8 16 -3 19 16 5

Exercise 2

Part (a)

Display contents of geomsum1 M-file

function s = geomsum2(r, a, n) e = 0:n-1; R = r.^e; s = sum(a * R); end disp('geomsum2 result:'); geomsum2 result: disp(geomsum2(9/11, 8, 10));

Exercise 3

Part (a)

Initiate product P. P = 1; Define starting iteration index. m = 2; Define stepsize of iteration. k = 2; Define ending iteration index. n = 18; Compute product. for i = m:k:n P = P * i; end disp('P (using for loop) ='); P (using for loop) = disp(P); 185794560 Display product.

P = prod(2:2:18); disp(P); 185794560

Part (b)

P = prod(2:2:18); disp(P); 185794560

Exercise 4

Initiate variables. power = 4; k = 1; Initialize the vector v to the empty vector v = zeros(1, ceil(log(1e7)/log(4))); % Preallocate vector size Compute powers and store in v. while power < 1e v(k) = power; power = power * 4; k = k + 1; end Display vector v. disp(v(1:k-1)); 4 16 64 256 1024 4096 16384

Exercise 5

Display contents of function f M-file.

disp('f(10) ='); disp(f(10)); f(10) = The function is undefined at x = 10 NaN Evaluate f at the given value of x. disp('f(11) ='); disp(f(11)); f(11) = 11