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

this question has 4 parts please matlab is allowed only... The only language you

ID: 3718430 • Letter: T

Question


this question has 4 parts please matlab is allowed only... The only language you should use is matlab... Thx

Name: GTID (903XxXxxx, ctc.): Problem 4. Answer the following short coding and multiple-choice tracing questions. (25 points) For parts a and b, consider the following function: 1 function theBeatles(file) 3 fh2 fopen([file(1:end-4) '_edit.txt', 'w') 5 while ischar(line) fhl fopen(file) : line fgetl (fhl) -isempty (strfind (line, fprintf (fh2, line) i if 'sun') ) end if isempty(strfind (line, 'And') ) end line fgetl (fh1) 10 line fgetl (fhl) 12 13 end 14 fclose (fhl) 15 fclose (fh2) 16 end a. The following text file, HereComesThesun.txt, is saved in your current directory: Here comes the sun (doo doo doo doo) Here comes the sun And I say It's all right The following line is run in the Command Window: theBeatles (HereComesTheSun.txt) What will the outputted text file, HereComesTheSun edit.txt, look like? (5 points) Here comes the sunHere comes the sun O Here comes the sun Here comes the sun Here comes the sun Here come s the sun And I say

Explanation / Answer

1) The output of the script will be

Here comes the sun

Here comes the sun

2) The while loop will learn 5 times, each time for the new line

3) The 2nd statement will suffice the conditions mentioned in the question

4) function rickUnroll(file)
fh1 = fopen(file);
fh2 = fopen([file(1: end-4) '_edit.txt'], 'w');
line = fget1(fh1);
while ischar(line)
if ~isempty(strfine(line, 'Never'))
fprintf(fh2, fliplr(line));
end
line = fget1(fh1);
end
fclose(fh1);
fclose()fh2;
end