Performing pdist2 in a for-loop with varying lengths of arrays
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
I have a for loop that calls a .mat file one by one from a folder and compares it to a separate baseline .mat file. My code (has been modified for readability) goes something like this:
a = load ('H:\Actor 01 Normal Intensity Only\Actor01.mat
%baseline .mat file
%then loads the baseline data into array
neutralRMSdata = a.RMSFramesMat;
for k = 1:length(myFiles)
%runs through the folder
%file information
baseFileName = myFiles(k).name;
FileName=[baseFileName,num2str(baseFileName)] ;
fullFileName = fullfile(myfolder, baseFileName);
%loads the data for the file that I want to compare to baseline neutralRMS
b = load (fullFileName);
%puts it into an array, size varies as the loop runs through the 32 files!!!
FileRMSdata = b.RMSFramesMat;
EucDist = pdist2(neutralRMSdata, FileRMSdata, 'hamming');
%this doesn't work because the size of FileRMSdata isn't the same as the neutralRMS array,
%and the size of the FileRMSdata changes with each loop iteration
end
So I need to be able to compare the length of the FileRMS each loop iteration with the length of NeutralRMS, and then either
a) pad the end of the shorter file with NaN values in order to complete the pdist2.
b) interpolate the shorter of the two arrays and then I should be able to run pdist2
Any help welcome!! Thanks, Chris
Any ideas?
댓글 수: 0
답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!