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

Use fprintf to display answers 8. Create the following string using the colon op

ID: 3876267 • Letter: U

Question

Use fprintf to display answers

8. Create the following string using the colon operator, and only the letters ‘A' and 'K' Letters = 'ABCDEFG HIJK, Create the following words in MATLAB using only the elements of “Letters" a. i. BAD ii. CAB ili. KICK v. CAKE Change the 5th element of Letters to the letter X and the last element of Letters to the letter Z in one short command. (Find the concise approach. Hint: refer to the top of this assignment and read the list of skills this assignment is designed to test. Which skill has not been tested by the other problems?) Extract in reverse every other element of Letters in one short command. The result would be: ZIGXCA' b. c.

Explanation / Answer

SAVE THE FOLLOWING COMMAND IN MATLAB AND GET THE RESULTS ACCORDINGLY TO YOUR PAPER-

clc

clear

close all;

str='A':1:'K';

%% Part(A)

%% (A)

a=str(2);

b=str(1);

c=str(4);

word=[a b c];

%% (B)

A=str(3);

B=str(1);

C=str(2);

second_word=[A B C];

%% (C)

q=str(11);

w=str(9);

e=str(3);

third_word=[q w e q];

%% (D)

Q=str(3);

W=str(1);

E=str(11);

R=str(5);

fourth_word=[Q W E R];

%% Part (B)

str([5 11])='XZ';

%% Part (C)

reverse_word=str([11 9 7 5 3 1]);