From: Catalin Eberhardt on 3 Aug 2010 07:01 Hi everyone, I have two MAT files that each contain many variables. The variables in the two MAT files are almost identically but, crucially, one of the variables has a different value in one MAT file than the value it has in the other MAT file. With many of the variables being cell arrays, it is very difficult to compare them manually in order to find the variable that is different. Is there any easier way of making this comparison? Many thanks in advance!
From: us on 3 Aug 2010 07:14 "Catalin Eberhardt" <longtalker(a)gmail.com> wrote in message <i38stf$5d8$1(a)fred.mathworks.com>... > Hi everyone, > > I have two MAT files that each contain many variables. The variables in the two MAT files are almost identically but, crucially, one of the variables has a different value in one MAT file than the value it has in the other MAT file. > > With many of the variables being cell arrays, it is very difficult to compare them manually in order to find the variable that is different. Is there any easier way of making this comparison? > > Many thanks in advance! one of the solutions s1=load('file1'); s2=load('file2'); fn=fieldnames(s1); for i=1:numel(fn) if isfield(s2,fn{i}) if ~isequalwithequalnans(s1.(fn{i}),s2.(fn{i})) disp(sprintf('different values: variable %s',fn{i})); end else disp(sprintf('S2.field missing: %s',fn{i})); end end us
From: Catalin Eberhardt on 3 Aug 2010 07:24 Many thanks for your help. The problem is that each MAT file only contains one structure array, which then contains all the different (sub)variables, and it's those "subvariables" that I need to compare... Your solution only tells me that the two structure arrays are different, but not *where* they are different. I'm afraid I don't enough about structures to make the necessary additions to your code...
From: us on 3 Aug 2010 07:53 "Catalin Eberhardt" <longtalker(a)gmail.com> wrote in message <i38u8k$1mk$1(a)fred.mathworks.com>... > Many thanks for your help. The problem is that each MAT file only contains one structure array, which then contains all the different (sub)variables, and it's those "subvariables" that I need to compare... Your solution only tells me that the two structure arrays are different, but not *where* they are different. I'm afraid I don't enough about structures to make the necessary additions to your code... well, if i understand you correctly, your MAT-file contains a STRUCT... then, change this s1=load('file1'); s1=s1.yourstructname % now, S1 is YOURSTRUCTNAME with all its fields... % same for S2 % rest of code... us
From: Catalin Eberhardt on 3 Aug 2010 10:06 Many thanks for your help, I really appreciate it.
|
Pages: 1 Prev: connected component labeling Next: code for adhoc network |