I want to search for strings in a text file 'marine_forservers.txt' according to the indices saved in 'x.txt' and then save those strings in output file This is the code I tried but it can't save strings to files Can anyone help me??
search = importdata('marine_forservers.txt');
patterns=importdata('x.txt');
fid = fopen('outputI.txt','w');
for i=1:length(patterns)
for j = 1:16709
if(j==patterns(i))
str= search(j);
fprintf(fid, '%s\n', str);
end
end
end
fclose(fid);
I got this Error in ==> suppI at 8 fprintf(fid, '%s\n', str);
stris not a string. Can you provide an example (in the question) of whatsearchandpatternslook like? Perhaps we can eliminate that double loop and fix your problem in one hit... ps I don't know who down-voted this but it is not obvious to me why it received a downvote?ismemberandintersect.