Prev: vrml and .mat file
Next: display image for comparison
From: Mohammad on 18 Jun 2010 13:40 But I don't know any three of those values. They fluctuate and I want to make it so that as they change, they never add up to a noninteger "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hvgad1$dc3$1(a)fred.mathworks.com>... > "Mohammad " <jaber2(a)uni.uiuc.edu> wrote in message <hvg7hl$emv$1(a)fred.mathworks.com>... > > Hi guys. > > > > I currently have a plotting function, trail5(m,n,o) where I want to make sure that at any time m+n+o=integer. I also want to make trail5(m,n,o)=plot with values of 1 through d in stems of 1/2, 1 through g in stems of 1/2, 1 through h in stems of 1/2, in order to make many copies of my image. (I input d,g,h as a boundary) > > > > For the m+n+o=integer part, I've tried to build off a suggestion of a nested for loop: > > > > for m=1:.5:d > > for n=1:.5:g > > for o=1:.5:h > > V = n+m+o; > > if V~=floor(V) > > trail5(m,n,o) %what I want to solve for in every possible value of m,n,o > > end > > end > > end > > end > > > > Is there a simple way to fix this so that trail5(m,n,o) works, and so that m+n+o=integer? > > > > Gosh. Think. > > Suppose I knew the values of m and n? > > Would I be able to compute EXACTLY which values of o > would assuredly generate an integer in the aggregate > value (m+n+o)? > > So why not just loop over m and n? > > Can you do even better? Suppose I knew the value of m? > I.e., you know that it is either already an integer, so either > both n and o must be integers, or both n and o must be > half integers. > > This allows you to employ only a single loop, coupled > with two calls to meshgrid. Of course, if things are small > enough, just make one call to meshgrid, or ndgrid, and > test the sum. > > John
From: John D'Errico on 18 Jun 2010 13:51 "Mohammad " <jaber2(a)uni.uiuc.edu> wrote in message <hvgb25$pni$1(a)fred.mathworks.com>... > But I don't know any three of those values. They fluctuate and I want to make it so that as they change, they never add up to a noninteger As you have written it, you DO know them. You are looping over their values. So inside a loop on m and n, you DO know their values. Given m and n, what values of o are possible? These are not just randomly fluctuating as you have written it. So you cannot say they are, because your own code shows that to be wrong. John
From: Mohammad on 18 Jun 2010 16:35 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hvgbm8$60i$1(a)fred.mathworks.com>... > "Mohammad " <jaber2(a)uni.uiuc.edu> wrote in message <hvgb25$pni$1(a)fred.mathworks.com>... > > But I don't know any three of those values. They fluctuate and I want to make it so that as they change, they never add up to a noninteger > > As you have written it, you DO know them. You are looping > over their values. So inside a loop on m and n, you DO > know their values. Given m and n, what values of o are > possible? > > These are not just randomly fluctuating as you have written > it. So you cannot say they are, because your own code > shows that to be wrong. > > John Oh. Are you saying I should take the first value of m, and find possible n and o. Then the second value m, third.... I'm a new user so I'll try to understand if you already showed me? If not, then could you explain how to do syntax. But that is a great idea :) (I have no idea how to vectorized it {what does that mean} but if it makes this a lot easier, I'd be happy to learn:) Thanks!
From: John D'Errico on 18 Jun 2010 21:00
"Mohammad " <jaber2(a)uni.uiuc.edu> wrote in message <hvgla7$i2c$1(a)fred.mathworks.com>... > "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <hvgbm8$60i$1(a)fred.mathworks.com>... > > "Mohammad " <jaber2(a)uni.uiuc.edu> wrote in message <hvgb25$pni$1(a)fred.mathworks.com>... > > > But I don't know any three of those values. They fluctuate and I want to make it so that as they change, they never add up to a noninteger > > > > As you have written it, you DO know them. You are looping > > over their values. So inside a loop on m and n, you DO > > know their values. Given m and n, what values of o are > > possible? > > > > These are not just randomly fluctuating as you have written > > it. So you cannot say they are, because your own code > > shows that to be wrong. > > > > John > > Oh. Are you saying I should take the first value of m, and find possible n and o. Then the second value m, third.... I'm a new user so I'll try to understand if you already showed me? If not, then could you explain how to do syntax. But that is a great idea :) (I have no idea how to vectorized it {what does that mean} but if it makes this a lot easier, I'd be happy to learn:) > > Thanks! I said this before. Write a nested pair of loops over m and n. This is the easy way to do it. Inside that loop, it will be trivial to determine those values of o that make the sum of all three numbers an integer, because you know the value of (m+n) inside those loops. You can do this yourself. In fact, I would claim it to be almost trivial, but I won't do it for you. If you really cannot do it, then it makes it even more obvious that you need to start reading the manual. John |