strfind returns empty cell despite that the strings contain same characters
I have big data file which I mapped using memmapfile and then change it to char. then I randomly generate a number and check whether the data contain this number using strfind. Although the generated number is within the data, command returns empty array.
datamap=memmapfile(‘file.txt’);
datachar=transpose(char(datamap.Data));
r = (r2-r1).*rand(1,1) + r1; %random number in range r1 r2
strfind(num2str(r),datachar)
I also tried sprintf to make sure both inputs are strings. when I inserted sprintf(datachar) I got warning: Control Character ” is not valid. See ‘doc sprintf’ for control characters
valid in the format string. … not sure if this can cause the problem. the data set contains numbers, strings, t for tabulator, n for end of the row and N which should be handled as string but might cause a problem…?
Thanks for any suggestions.I have big data file which I mapped using memmapfile and then change it to char. then I randomly generate a number and check whether the data contain this number using strfind. Although the generated number is within the data, command returns empty array.
datamap=memmapfile(‘file.txt’);
datachar=transpose(char(datamap.Data));
r = (r2-r1).*rand(1,1) + r1; %random number in range r1 r2
strfind(num2str(r),datachar)
I also tried sprintf to make sure both inputs are strings. when I inserted sprintf(datachar) I got warning: Control Character ” is not valid. See ‘doc sprintf’ for control characters
valid in the format string. … not sure if this can cause the problem. the data set contains numbers, strings, t for tabulator, n for end of the row and N which should be handled as string but might cause a problem…?
Thanks for any suggestions. I have big data file which I mapped using memmapfile and then change it to char. then I randomly generate a number and check whether the data contain this number using strfind. Although the generated number is within the data, command returns empty array.
datamap=memmapfile(‘file.txt’);
datachar=transpose(char(datamap.Data));
r = (r2-r1).*rand(1,1) + r1; %random number in range r1 r2
strfind(num2str(r),datachar)
I also tried sprintf to make sure both inputs are strings. when I inserted sprintf(datachar) I got warning: Control Character ” is not valid. See ‘doc sprintf’ for control characters
valid in the format string. … not sure if this can cause the problem. the data set contains numbers, strings, t for tabulator, n for end of the row and N which should be handled as string but might cause a problem…?
Thanks for any suggestions. strfind sprintf num2str string MATLAB Answers — New Questions