I have written the function to compare two text files as sho
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?