how to use for loop to compute a matrix
Show older comments
Hello. I'm a beginner at Matlab.
I want to use for loop.
I got data (25 x 12852) using this code.
I want to concatenate the matrix (dist).
For example, the last part of whole code,
dist = dtw(data(:,1),data(:,2));
dist = dtw(data(:,2),data(:,3));
dist = dtw(data(:,3),data(:,4));
dist = dtw(data(:,4),data(:,5));
dist = dtw(data(:,5),data(:,6));
......
dist = dtw(data(:,12851),data(:,12852));
Finally, I want to get one matrix.
Can I get an idea to solve this?
Also, is it resonalble to use dynamic time warping (DTW) for video classification?
clear all
close all
%// read the video:
list = dir('*.avi')
% loop through the filenames in the list
for k = 1:length(list)
reader = VideoReader(list(k).name);
vid = {};
while hasFrame(reader)
vid{end+1} = readFrame(reader);
end
%// estimate foreground as deviation from estimated background:
cellSize = [8 8];
for i=1:25
fIdx(i) = i; %// do it for frame 1 ~ 60
frameGray{i} = vid{fIdx(i)};
[featureVector{i},hogVisualization{i}] = extractHOGFeatures(frameGray{i},'CellSize',cellSize);
end
data = cell2mat(featureVector');
data = double(data);
dist = dtw(data(:,5),data(:,6));
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!