I have written the function to compare two text files as shown belowfunction [testStatus, testMessage] = compare2TxtFiles(File1, File2)% DESCRIPTION% This functions compares two text file%% INPUTS:% File1 – Name of the reference text file% File2 – Name of the text file to be compared with the reference text file%% OUTPUTS:% testMessage – Prints unmatched results of the comparison% testStatus – Returns logical 1 if files matches and logical 0 otherwise% Initialize outputstestStatus = 1;testMessage = {};% Open, read each line (row) and close the first text file% Opens the first (reference) text file File1 for readingFID = fopen(File1, ‘r’); % Reads File1 data into a cell array DataData = textscan(FID, ‘%s’, ‘delimiter’, ‘n’, ‘whitespace’, ”); % Returns the first line of cell array of strings Data to lines1lines1 = Data{1}; % Close the opened first filefclose(FID); % Open, read each line (row) and close the second text fileFID = fopen(File2, ‘r’);Data = textscan(FID, ‘%s’, ‘delimiter’, ‘n’, ‘whitespace’, ”);lines2 = Data{1};fclose(FID);% Get the number of elements in cellOneData1 and cellOneData2% Number of elements in array lines1numElOfLines1 = numel(lines1);% Number of elements in array lines2numElOfLines2 = numel(lines2); % Compare the content the cell arrays lines1 and lines2for i=1:numElOfLines1 % If number of lines in lines1 are less than that of lines2 if i <= numElOfLines2 if strcmp(lines1{i},lines2{i})== 1 else testStatus = 0; outText = [‘Line ‘ num2str(i) ‘:’ ‘ ‘ lines1{i} ‘ Is different from: ‘ lines2{i}]; testMessage{end+1} = sprintf(outText); end else % If number of lines in lines1 are more than that of lines2 if i > numElOfLines2 testStatus = 0; outText = ‘Not Necessary to Compare the Files’; testMessage{end+1} = sprintf(outText); return; end end endBut when i run the code, I do not get the expected results. The problem is that when I run the test, I get ‘Not Necessary to compare files’ printed in the results of all the test cases.Please can someone identify why i am having this problem and solve it?
Posted on by admin
I have written the function to compare two text files as sho
WHAT OUR CURRENT CUSTOMERS SAY

- Google

- Sitejabber

- Trustpilot
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!

Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.

Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.

Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!


Jermaine Byrant
Nicole Johnson



