필터 지우기
필터 지우기

How to solve the problem of finding several similar names?

조회 수: 2 (최근 30일)
omid
omid 2023년 5월 26일
답변: Walter Roberson 2023년 5월 26일
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=[];

채택된 답변

Walter Roberson
Walter Roberson 2023년 5월 26일
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개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by