Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the array A. A = [3 -8 -17 5 -1 6 -4 33 -9] Write a program that comput

ID: 3110166 • Letter: C

Question

Consider the array A. A = [3 -8 -17 5 -1 6 -4 33 -9] Write a program that computes the array B by computing the natural logarithm of all the elements of A whose value is no less than 1, and adding 20 to each element that is equal to or greater than 1. Do this in two ways: a. By using for loop with conditional statements. B. By using a logical array a mask. Use a while loop to determine how many terms in the series 2^k, k = 1, 2, 3, ..., are required for the sum of the terms to exceed 2000. What is the sum for this number of terms?

Explanation / Answer

clc;
clear all;
close all;
A=[3 5 -4;-8 -1 33; -17 6 -9];
[m,n]=size(A);
for i=1:m
for j=1:n
B(i,j)=log(A(i,j));
if (B(i,j)>=1)
B(i,j)=B(i,j)+20;
end
end
end

%%%%
B1=log(A);

%%%%%
sum=0;
k=1;
while ( sum < 2000)
sum=sum+ 2^k;
k=k+1;
end

Num_trms=k-1; %%%% number of terms befor sum exceeding 2000
f_sum= sum-2^(k-1); %%%% final sum

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote