Compare Nested Cell & Struct Arrays Recursively

버전 1.0.0.1 (3.74 KB) 작성자: Ameya Deoras
Compare two cell or struct arrays and find exactly where they differ
다운로드 수: 1.6K
업데이트 날짜: 2016/9/1

라이선스 보기

This package contains two functions CELLEQ and STRUCTEQ which compare two cell arrays or two structures respectively. The cells/structs may internally contain more nested cell and struct arrays which are compared recursively.
Feature summary:
* Support for nested structures/cell arrays
* Return of full stack information on where the two cells/structs differ
* Control for comparison of Function handles within structs/cells
* Control for comparison of NaN properties

Usage:
[iseq, info]= celleq(cell1, cell2, funh2string, ignorenan)
[iseq, info] = structeq(struct1, struct2, funh2string, ignorenan)

* iseq is true if all elements and subelements of the two cells or structs are identical
* info is a structure that contains a field "Reason" which gives you a text stack of why the difference occurred as well as a field "Where" which contains the indices of the element and subelement where the comparison failed.
* (optional) funh2string, if true, instructs function handle comparisons to return true if the string representations of the function handles are the same.
* (optional) ignorenan, if true, will return true for nan == nan. By default both properties are set to false

Example:
>> figure;
>> g = surf(peaks(50));
>> rotate3d
>> hg1 = handle2struct(gcf);
>> set(g,'XDataMode', 'manual');
>> hg2 = handle2struct(gcf);

>> [iseq, info] = structeq(hg1, hg2)
iseq =
0
info =
Reason: [1x137 char]
Where: '(1).properties(1).KeyPressFcn{1}'

>> [iseq, info] = structeq(hg1, hg2, true)
iseq =
0
info =
Reason: [1x188 char]
Where: '(1).children(1).children(1).properties(1).XDataMode'

인용 양식

Ameya Deoras (2024). Compare Nested Cell & Struct Arrays Recursively (https://www.mathworks.com/matlabcentral/fileexchange/27542-compare-nested-cell-struct-arrays-recursively), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2009b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.1

Updated license

1.0.0.0