Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: i want to simplify this code
Replies: 14   Last Post: Apr 22, 2013 7:11 AM

 Messages: [ Previous | Next ]
 mohammed Posts: 18 From: egypt Registered: 12/10/07
i want to simplify this code
Posted: Mar 30, 2013 8:07 PM

hi guys ..
i have this code

[x2,y2,z2]=find(S==2);
for n2=1:length(x2);
I(x2(n2):x2(n2)+1,y2(n2):y2(n2)+1)=100;
end
[x4,y4,z4]=find(S==4);
for n4=1:length(x4);
I(x4(n4):x4(n4)+3,y4(n4):y4(n4)+3)=200;
end
[x8,y8,z8]=find(S==8);
for n8=1:length(x8);
I(x8(n8):x8(n8)+7,y8(n8):y8(n8)+7)=255;
end
[x16,y16,z16]=find(S==16);
for n16=1:length(x16);
I(x16(n16):x16(n16)+15,y16(n16):y16(n16)+15)=150;
end
[x32,y32,z32]=find(S==32);
for n32=1:length(x32);
I(x32(n32):x32(n32)+31,y32(n32):y32(n32)+31)=50;
end

but i feel it is too long and want to make it more simple
could anybody to help me ?

Date Subject Author
3/30/13 mohammed
4/6/13 mohammed
4/6/13 dpb
4/7/13 Bruno Luong
4/7/13 mohammed
4/7/13 mohammed
4/7/13 dpb
4/7/13 mohammed
4/7/13 dpb
4/7/13 mohammed
4/7/13 dpb
4/14/13 mohammed
4/22/13 Bruno Luong
4/22/13 Bruno Luong
4/7/13 mohammed