5. Create a MATLAB file and generate a geometric sequence using for loop (10 poi
ID: 2073434 • Letter: 5
Question
5. Create a MATLAB file and generate a geometric sequence using for loop (10 points): (a) 4, 8, 12, 16, 20, 24; (b) 38, 32, 26, 20, 14, 8.
6. Create a MATLAB file and generate a geometric sequence using colon operator (6 points): (a) 3, 6, 9, 12, 15, 18; (b) 35, 30, 25, 20, 15, 10
. 7. Create a MATLAB file and write a code to implement the following: (10 points): (a) Define a 5x5 zero matrix. Name the matrix as ‘A’ (use zeros function, see MATLAB help for more information) (b) Use for loop and if statement to transform matrix A into an identity matrix. Call the function “disp” to show your results.
8. Create a MATLAB file and write a code to implement the following: (8 points, 2 points each): (a) Ask the user for a 3x3 matrix input. Name the matrix as ‘A’ (b) Use that input to get an answer for A(3,1), A(2,3) and A(1,3) from (a) (c) Use if statement to check if the number in A(1,2) is positive and show the number, elseif to check if the number is ‘0’. If it is ‘0’ then included a statement “The number is zero”. (d) If the number is negative include a statement, “The number is negative”
Please just do as much as you can
Explanation / Answer
SOLVING QUESTION NO. 5
a)clear all
j=1;
n=0;
m=0;
for j=1:6
n=n+4;
m=n
fprintf('%d ',m);
j=j+1;
end
OUTPUT:
4
8
12
16
20
24
b)
CODE:
clear all
j=1;
n=44;
m=0;
for j=1:6
n=n-6;
m=n;
fprintf('%d ',m);
j=j+1;
end
OUTPUT:
38
32
26
20
14
8
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.