dimanche 6 septembre 2020

Matlab: Loops through the document to find the corresponding positions of different strings

I want to find the corresponding positions of different strings in a document and come up with specific content. This works when I look for the strings one by one separately.

SvLoc = [];
for i = 1 : n_line
    if ~isempty(cell2mat(strfind(data2(i,:), contents(1,4))))
        SvLoc = [SvLoc, i];  
        break;
    end
end

[Starting_Value bb] = strtok(data2(SvLoc+1,:),'<td align="right">');

But this is cumbersome, so I try to use a loop, but the following code doesn't work.

Loc = []; i = 1;
for i = i : n_line
    for j = 1 : line
    if j ~= line; %line = length(contents)
        ~isempty(cell2mat(strfind(data2(i,:), contents(1,j))))
        Loc = [Loc, i]; 
        break;
        i = i; j = j+1;
    else 
        disp('process completed')
    end
end

Is there something wrong with the code I wrote?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire