I have another quick question about matlab. If this is my matrix:
a=
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 4 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 1 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
I need to start at the 1 in the lower left hand corner, and go diagonally element by element to the 4 in the top right and change that value to a 1, the values of the other cells doesn't matter.
I started off by
p=size(a);
n=p(1);
m=p(2);
for i=1:1:n; %rows
for j=1:1:m; %columns
I'm stuck in here
end
end
a
this is where I'm stuck, I usually end up in an infinite loop somehow. I tried to use "find(a(i,j)=1)" to look for the value 1 then set that equal to a(i,j) and then do something like a(i+1,j+1) to go diagonal but it doesn't seem to work. any suggestions:
a=
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 4 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
3 1 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3
I need to start at the 1 in the lower left hand corner, and go diagonally element by element to the 4 in the top right and change that value to a 1, the values of the other cells doesn't matter.
I started off by
p=size(a);
n=p(1);
m=p(2);
for i=1:1:n; %rows
for j=1:1:m; %columns
I'm stuck in here
end
end
a
this is where I'm stuck, I usually end up in an infinite loop somehow. I tried to use "find(a(i,j)=1)" to look for the value 1 then set that equal to a(i,j) and then do something like a(i+1,j+1) to go diagonal but it doesn't seem to work. any suggestions: