Questions: 213

Answers by our Experts: 199

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

SuM is it a correct variable name
I. Examine the following for loops and determine how many times each loop will be executed. Show your solutions. Box your final answer.

1. for index = 7:10
2. for jj = 7:-1:10
3. for index = 1:10:10
4. for ii = -10:3:-7
5. for kk = [0 5 ; 3 3]
Examine the following for loops and determine the value of ires at the end of each of the loops and also the number of times each loop executes. Show your solutions.

1. ires = 0;
for index = 1:10
ires = ires + 1;
end

2. ires = 0;
for index = 1:10
ires = ires + index;
end

3. ires = 0;
for index1 = 1:10
for index2 = index1:10
if index2 == 6
break;
end
ires = ires + 1;
end
end

4. ires = 0;
for index1 = 1:10
for index2 = index1:10
if index2 == 6
continue;
end
ires = ires + 1;
end
end
Loops and flow control. Make function called loopTest(N) that loops through the values 1
through N and for each number n it should display ‘n is divisible by 2’, ‘n is divisible by 3’, ‘n is
divisible by 2 AND 3’ or ‘n is NOT divisible by 2 or 3’. Use a for loop, the function mod or rem to
figure out if a number is divisible by 2 or 3, and num2str to convert each number to a string for
displaying. You can use any combination of if, else, and elseif.
Fun with find. Write a function to return the index of the value that is nearest to a desired
value. The function declaration should be: ind=findNearest(x, desiredVal). x is a
vector or matrix of values, and desiredVal is the scalar value you want to find. Do not
assume that desiredVal exists in x, rather find the value that is closest to desiredVal. If
multiple values (entries) have the same distance from desiredVal, return all of their indices.
Test your function to make sure it works on a few vectors and matrices. Useful functions are
abs, min, and find. Hint: You may have some trouble using min when x is a matrix. To convert a
matrix Q into a vector you can do something like y=Q(:). Then, doing m=min(y) will give
you the minimum value in Q. To find where this minimum occurs in Q, do ind=find(Q==m);
1 – Create a message to be encrypted. The maximum length of the message is 1016 characters, and the program should be capable of handling a message of any length up to that number. It must check the length of the message and inform the user if it’s too long. Generate your selected encryption cypher and convert the message to the numerical equivalent. This must be done using loops
C= E= A=
16 2 3 13 1 0 0 0 1 2 3 4
5 11 10 8 0 1 0 0 6 8 1 5
9 7 6 12 0 0 0 1 9 4 2 7
4 14 15 1 1 0 0 0 9 4 7 2

B= D= F=
1 1 1 1 1 0 0 0 3 6 9 12
1 1 1 1 0 3 0 0 18 24 3 15
1 1 1 1 0 0 5 0 27 12 6 21
1 1 1 1 0 0 0 7 27 12 21 6

Expression

(4B+3D)/(2A2BC)

Write Matlab Expression and Result
C= E= A=
16 2 3 13 1 0 0 0 1 2 3 4
5 11 10 8 0 1 0 0 6 8 1 5
9 7 6 12 0 0 0 1 9 4 2 7
4 14 15 1 1 0 0 0 9 4 7 2

B= D= F=
1 1 1 1 1 0 0 0 3 6 9 12
1 1 1 1 0 3 0 0 18 24 3 15
1 1 1 1 0 0 5 0 27 12 6 21
1 1 1 1 0 0 0 7 27 12 21 6

Expression

(2B-3D)*(2ABC)

Write Matlab Expression and Result
C= E=
16 2 3 13 1 0 0 0
5 11 10 8 0 1 0 0
9 7 6 12 0 0 0 1
4 14 15 1 1 0 0 0

B= D= F=
1 1 1 1 1 0 0 0 3 6 9 12
1 1 1 1 0 3 0 0 18 24 3 15
1 1 1 1 0 0 5 0 27 12 6 21
1 1 1 1 0 0 0 7 27 12 21 6

Expression

FEB/2CD

Write Matlab Expression and Result.
E=
1 0 0 0
0 1 0 0
0 0 0 1
1 0 0 0

B= D= F=
1 1 1 1 1 0 0 0 3 6 9 12
1 1 1 1 0 3 0 0 18 24 3 15
1 1 1 1 0 0 5 0 27 12 6 21
1 1 1 1 0 0 0 7 27 12 21 6

Expression

2DEF+4B

Write Matlab Expression and Result
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS