How to solve the problem of finding several similar names?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
omid
am 26 Mai 2023
Beantwortet: Walter Roberson
am 26 Mai 2023
Hello friends, there are 2 problems in my code
1_ in the line "[row,column]=find(contains(filenamenew,string(filename)))" I am looking for the sample 9967, but the find command also finds other similar samples such as 49967 or 59967.
2=1- In the line "filenamenew{i}=(filename(:,1:end-7); " filenamenew is saved as a cell, I don't want this to happen
clc
clear
close all
cd training_data_out\
folderInfo = dir('**/*.wav');
cd ..\
addpath training_data_out\
load('ID.mat')
ID=trainingdataa(2:end,1);
ID=table2array(ID);
% working (current) folder
for i=1:length(folderInfo)
filename =folderInfo(i).name;
filenamenew{i}=(filename(:,1:end-7);
end
%BB=unique(id)
filename=[];
for id=1:length(ID)
filename =ID(id);
column=[];
[row,column]=find(contains(filenamenew,string(filename)));
total_im=[];
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Mai 2023
pat = digitboundary + filename + digitboundary;
[row,column]=find(contains(filenamenew, pat));
This constrains the search to cases where what is before and after the ID is something that is not a digit -- could be a beginning of string, could be a letter, could be a symbol such as '#" -- but not a digit. So ABC9967.mat could match but not ABC19967.mat or ABC99675.mat
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!