Matlab Programming

timer Asked: Apr 16th, 2016

Question description


The function compareTGZ is used to compare two tgz folders. The tgz folders contains the following types of files: - mat files and textual files such as .m, .ddf and .txt.

In this case, a function has to be designed to compare the contents of two .tgz files. The function is defined as follows: 

function [testStatus, testMessage] = compareTGZ(refTGZFile, newTGZFile)

This function has two input arguments and two output arguments. The input argument refTGZFile is the reference tgz file created before refactoring while the argument newTGZFile is the test tgz created after refactoring. 

The output testStatus is an argument that gives the status of the comparison of the two tgz files. It returns logical 1 if the two tgz files and their contents match and logical 0 if they do not match. The second output argument testMessage is a cell array that returns the unmatched lines of the identical files in the two tgz folders by calling the function compareTxtFile. It also returns the names of the files that are present in refTGZFile but not found in the newTGZFile. The .mat files are compared by calling the function comp_struct already existing in MATES.

The function 

[testStatus, testMessage] = compareTxtFiles(fnames_old{i}, fnames_new{i});

compares the textual file while the function 

[~, ~ , ~ , erc] = comp_struct(1,ref_mat,new_mat,1,1,1e-6,ref_mat_name,new_mat_name);

Compare the .mat files


In the file compareTGZ,  I want to add a condition in this function to check if refTGZFile contains more files than the newTGZFile

For example: file x is present in refTGZFile but not in the newTGZFile

It should return

File x in Reference tgz is not found in Test tgz

And the condition to check if newTGZFile contains more files than the refTGZFile

For example: file y is present in newTGZFile but not in the refTGZFile

It should return

File x in Test tgz is not found in Reference tgz


Modify the code so that there will be no command window outputs by default. The output is produced if and only if requested by user. 


Change the fprintf to sprintf

This can be done in a test function by using disp()

For example: see the script - scriptTestCompareTGZ.m

% Call the function

[ts,tm]= compareTGZ(refFile,testFile);

if ts == 0 

    for n=1:numel(tm)






Please let me know if you can do it so that I can send the codes

Tutor Answer

(Top Tutor) Studypool Tutor
School: UT Austin
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors