MATLAB: How to locate a string in Matlab, getting the index of the string indexMATLABmatlab string index locatestring I'm a newbie to Matlab and have a question about str locating: A = ['abc','de','fghij','something','another']; Then how can I get `3` if I use `strfind(A,'fghij')`? Thanks. Best Answer A = {'abc','de','fghij','something','another'} idx=find(ismember(A,'fghij')) Related SolutionsMATLAB: Binary string to character string userid = char(bin2dec(reshape(watermark(1:160),[],8))).'passwrd = char(bin2dec(reshape(watermark(161:320),[],8))).'str = [userid passwrd] MATLAB: Replacing Occurrences of String please try this is code:out = input_sentence;ii = strfind(out,str1)if ~isempty(ii) for ii = ii out = [out(1:ii-1),str2,out(ii+numel(str1):end)]; endendorout = input_sentence;[i1,i2] = regexp(out,str1);if ~isempty(i1) for ii = 1:numel(i1) out = [out(1:i1(ii)-1),str2,out(i2(ii)+1:end)]; endendorout = regexprep(input_sentence,str1,str2);orout = strrep(input_sentence,str1,str2); Related QuestionHow to compare stringHow to change gui stringHow to limit a stringHow to compact a stringOutput of sprintf – stringHow can colour a string
Best Answer