Performing pdist2 in a for-loop with varying lengths of arrays
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 15 Feb. 2018
How about
if isequal(a, b)
% Structures a and b match completely.
end
2 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!