



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 7
This page cannot be seen from the preview
Don't miss anything!




b = [26; 1; 8]; c = [2 5 -2]; d = [3; 2; 0]; AB = A * B; BA = B * A; cA = c * A; Bd = B * d;
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
x = A \ b; disp('x ='); disp(x); x = -0.
-0.
disp('Modified A ='); disp(A); Modified A = -9 6 - 5 -2 - -3 -2 0
a = A(2, :); disp('a ='); disp(a); a = 5 -2 -
disp('Modified B ='); disp(B); Modified B = 8 16 -3 19 16 5
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));
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
P = prod(2:2:18); disp(P); 185794560
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
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