두 개의 다른 .mat 파일에서 두 개의 행렬을 비교해야합니다. 즉, 두 개의 다른 파일이 있습니다. file1.mat 및 file2.mat, 각 파일에는 3 개의 행렬이 있습니다.
File1.mat = (M11, M12, M13) Fileé.mat = (M21, M22, M23)
M11과 M21을 비교해야합니다.
function [Matrice_Result]= difference ()
R1=importdata('file1.mat')
R2=importdata('file2.mat')
Matrice_Result= R1== R2
endfunction
내가 찾은 오류는 다음과 같습니다.
error: binary operator '==' not implemented for 'scalar struct' by 'scalar struct' operations
error: called from differences at line 6 column 9
도와 주시면 감사하겠습니다.
.mat
파일에서 작업 공간으로 데이터를로드하는 가장 쉽고 / 가장 적절한 방법 은 load
명령을 사용하는 것입니다. 하나의 변수 (당신이 알고있는 이름) 만 작업 공간으로 가져올 수 있습니다.
변수에 할당하지 않고 단순히 load 명령을 실행하여이를 수행 할 수 있습니다.
>> load ('file1.mat', 'M11');
>> load ('file2.mat', 'M21');
>> whos
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
M11 1x3 24 double
M21 1x3 24 double
Total is 6 elements using 48 bytes
>> isequal (M11, M21)
ans = 1
당신이 그러나 할 변수로 수집,이 변수가 될 구조체 그 fieldName에 가져온 변수의 이름, 예를 들면 대응은,
>> S1 = load ('file1.mat', 'M11');
>> S2 = load ('file2.mat', 'M21');
>> isequal (S1.M11, S2.M21)
ans = 1
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다