필터 지우기
필터 지우기

I want to save my data from .mat file to csv file. I tried many methods but its not working.

조회 수: 2 (최근 30일)
Here is my code and results are attached in image.
myFolder = 'folder'; % or whatever.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.jpg');
matFiles = dir(filePattern);
X = cell(length(matFiles), 1);
for k = 1:length(matFiles)
baseFileName = matFiles(k).name;
img = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', img);
storedStructure = imread(img);
% Now do whatever you need to do with the structure you recalled.
%figure % New figure, do not specify the index
%imshow(img);
FaceDetect = vision.CascadeObjectDetector;
FaceDetect.MergeThreshold = 7 ;
BB = step(FaceDetect,storedStructure); %figure(2),imshow(img);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','- ','EdgeColor','r');
end
% figure
for i = 1:size(BB,1)
J= imcrop(storedStructure,BB(i,:));
%subplot(6,6,i);
figure
imshow(J);
% Create a folder with the base file name
[~, baseFileNameNoExt, ~] = fileparts(baseFileName);
outputFolder = fullfile(myFolder, baseFileNameNoExt);
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
fprintf('Created folder : %s\n', outputFolder);
end
% Prepare output filename
outputFileName = fullfile(outputFolder, baseFileName);
% Write file to that folder
imwrite(J, outputFileName);
fprintf(' Copied %s to the folder called %s.\n', baseFileName, outputFolder);
end
X{k} = [x{k} HOG(J)'];
save('features.mat','J');
end

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 2일
Save the cell array like this
csvwrite('features.csv', cell2mat(x))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by