フィルターのクリア

I would like to move pictures from a file into another under a condition, which I have in Excel

1 回表示 (過去 30 日間)
Eren
Eren 2023 年 10 月 2 日
コメント済み: Harald 2023 年 10 月 4 日
% Pfad zur Excel-Datei
excelDatei = 'Excelpath\excelfile.xlsx';
% Laden Sie die Excel-Tabelle in MATLAB
data = xlsread(excelDatei); % Annahme: Die Tabelle hat zwei Spalten, 'ImageNames' und 'Classification'
% Quell- und Zielordner definieren
srcOrdner = 'Sourcefilepath'; % Ersetzen Sie durch den Pfad zu Ihrem Quellordner
zielOrdner = 'Destinationfilepath'; % Ersetzen Sie durch den Pfad zu Ihrem Zielordner
% Schleife durch die Daten und verschieben Sie die Bilder
for i = 1:size(data, 1)
imageName = data{i, 1}; % Annahme: Die Bildnamen sind in der ersten Spalte
classification = data{i, 2}; % Annahme: Die Klassifikation ist in der zweiten Spalte
% Überprüfen Sie die Klassifikation (z.B., Bild ist nicht 14)
if classification ~= 14
srcPfad = fullfile(srcOrdner, [imageName '.png']);
zielPfad = fullfile(zielOrdner, [imageName '.png']);
% Verschieben Sie das Bild in den Zielordner
copyfile(srcPfad, zielPfad);
end
end
disp('Bilder wurden basierend auf der Tabelle verschoben.');
I don't get an error while using the code but it does not move the pictures out of the file into a new one.
The following shows my excel sheet. The idea is to move pictures out of the file which are classified different then 14.
ImageNames Classification
00014_00000_00000 14
00014_00000_00001 14
00014_00000_00002 2
00014_00000_00003 14
00014_00000_00004 14

回答 (1 件)

Harald
Harald 2023 年 10 月 4 日
Hi,
use debugging to see what the values of classification are. Apparently, they are not 14 - maybe '14' or "14"? The isequal function may be helpful for the query.
Without access to the spreadsheet, it's hard to tell.
Since this seems to be some kind of assignment, I would also consider consulting the instructor.
Best wishes,
Harald
  2 件のコメント
Eren
Eren 2023 年 10 月 4 日
Thank you for your answer :)
Harald
Harald 2023 年 10 月 4 日
Hi Eren,
if this answer has solved the problem for you, please also consider to "accept" it.
Thanks and best wishes,
Harald

サインインしてコメントする。

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!