Matlab programmingSolutionfunction outrows outcols findSe
Solution
function [ outrows, outcols ] = findSeqFromMat( seq, mat )
     [ rows, cols ] = size(mat);
     outrows = [];
     outcols = [];
     tElems = size(seq,2);
     for r=1:rows
         for c=1:cols
             if mat(r,c) == seq(1)
                 %look if complete sequence matches
                 pushInAnswer= 0;
                 %horizontally
                 if c+ tElems-1 <= cols
                     pushInAnswer = 1;
                     for i=0:tElems-1
                         if mat(r,c+i) ~= seq(i+1)
                             pushInAnswer= 0;
                         end
                     end
                 end
 % remove comments, if vertical sequence is also to be detected
 %                 if pushInAnswer == 0
 %                     %try vertically
 %                     if r+ tElems-1 <= rows
 %                         pushInAnswer = 1;
 %                         for i=0:tElems-1
 %                             if mat(r+i,c) ~= seq(i+1)
 %                                 pushInAnswer= 0;
 %                             end
 %                         end
 %                     end
 %                 end
                 if pushInAnswer == 1
                     outrows = [outrows r];
                     outcols = [outcols c];
                 end
             end
         end
     end
 end
![Matlab programmingSolutionfunction [ outrows, outcols ] = findSeqFromMat( seq, mat ) [ rows, cols ] = size(mat); outrows = []; outcols = []; tElems = size(seq,2 Matlab programmingSolutionfunction [ outrows, outcols ] = findSeqFromMat( seq, mat ) [ rows, cols ] = size(mat); outrows = []; outcols = []; tElems = size(seq,2](/WebImages/31/matlab-programmingsolutionfunction-outrows-outcols-findse-1089530-1761573455-0.webp)
