For loops to take specific values only in MATLAB -



For loops to take specific values only in MATLAB -

i have matlab programme uses 2 for loops iterate 5 times. however, want matlab utilize (1 1), (2 2), (3 3) , on.

here program:

syms l = [0 1 0 0 1 0;1 1 1 0 1 1;1 0 0 0 1 1;1 1 1 0 0 1;0 1 1 0 1 1]; n = [2 1;1 1;1 1;1 1;2 1]; l = 1:5 = 1:5 j = n(l,1); if a(i,j) == 0 a(i,j:end) = circshift(a(i,j:end),[n(l,2) n(l,2)]); j = n(l,1):n(l,1)+n(l,2) a(i,n(l,1)) = 1; end else a(i,j:end) = circshift(a(i,j:end),[n(l,2) n(l,2)]); j = n(l,1):n(l,1)+n(l,2) a(i,n(l,1)) = 0; end end break; end break; end

i want matlab programme work this:

first l = 1 , = 1; sec l = 2 , = 2; 3rd l = 3 , = 3; 4th l = 4 , = 4;

and on...

@rodyoldenhuis answered question, , i'm flattered hasn't made actual answer!

simply take code , alter inner for loop index matches outer loop index. in other words, this:

syms l %// why doing this? = [0 1 0 0 1 0;1 1 1 0 1 1;1 0 0 0 1 1;1 1 1 0 0 1;0 1 1 0 1 1]; n = [2 1;1 1;1 1;1 1;2 1]; l = 1:5 = l; %// alter here - remove sec loop %// ... [rest of code here] %// rid of break in loop end %// removed break here end

matlab for-loop

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -