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

3) Write a MATLAB program that traverses the following text, replacing the occur

ID: 2262188 • Letter: 3

Question

3) Write a MATLAB program that traverses the following text, replacing the occurrences of letter 'w' with its capital W and the capital W with its lower case w, finally the capital W for the number of occurrences). it tells you how many occurrences of 'w' there were in your text (ignore Wayne went to Wales to watch walruses, whales, waryfish and whiting Store both the original and modified text strings in a text file called 'Waynetext.brt Avoid using the 'strep' MATLAB command and equivalent commands

Explanation / Answer

fileID = fopen('Waynetext.txt','w');
str=['Wayne went to Wales to watch walruses,whales waryfish and whiting'];
c=0;
fprintf(fileID, str);
fprintf(fileID, ' ');
for i=1:length(str);
if str(i)=='w';
str(i)= 'W';
c=c+1;
  
elseif str(i)=='W';
str(i)= 'w';
end
end

fprintf(fileID, str);
type('myfile.txt')
disp(c);
fclose(fileID);

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