matlab - How to run the code for same value of two variable -


i have written following code-

  t=0:4     i=5         b=[1,1,1,1,1;1,1,1,2,0;1,1,3,0,0;1,2,2,0,0;1,4,0,0,0;2,3,0,0,0;5,0,0,0,0];         a=b;         b(b==0)=inf;         idx = (a(:,i-t)==1 );         = a(idx,:);     end end 

now problem can run code t=0:i-1 want run code for t=0:i when tried same value of i , t shows error.it because i-t=0 means index 0 in matlab index never 0.

in case when i-t=0 take value of a unable write code condition.

matlab experts need , suggestions regrading code.

use if condition handle case specially...

if == t   idx = (a == 1);   = a(idx); else   idx = (a(:,i-t)==1 );   = a(idx, :); end 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -