How to solve the problem of finding several similar names?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
omid
el 26 de Mayo de 2023
Respondida: Walter Roberson
el 26 de Mayo de 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 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!