Prev: replace values in a cell with nan
Next: Simulink Pulse Generator with amplitude between -1 and +1
From: James Tursa on 10 Feb 2010 20:19 "sean " <jssweeney(a)widener.edu> wrote in message <hkvliv$f3s$1(a)fred.mathworks.com>... > What is the simplest way to do this? > x=1 > y=2 > I want to assign the larger number to 'c'. I can think of a few ways, but there must be an easier way. Any builtin to handle this? Thanks. Hmmm ... so you want to assign the max of the two values to c ... hmmm ... the max of the two values to c ... that's a tough one ...
From: Matt Fig on 10 Feb 2010 20:22 Or simply c = max(x,y)
From: sean on 10 Feb 2010 20:25 Thank you for the reply. I thought 'max' would work too, but I get either of these two errors depending on the integer status of x and y. Any ideas? ============ EDU>> x=1 x = 1 EDU>> y=2 y = 2 EDU>> max([x y]) ??? Index exceeds matrix dimensions. EDU>> x=1.1 x = 1.1000 EDU>> y=2.2 y = 2.2000 EDU>> max([x y]) ??? Subscript indices must either be real positive integers or logicals. ============= ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f9ecaae3-fb0e-4817-8083-db2876714abf(a)b2g2000yqi.googlegroups.com>... > c = max([x y])
From: sean on 10 Feb 2010 20:29 EDU>> x=1 x = 1 EDU>> y=2 y = 2 EDU>> c=max(x,y) ??? Index exceeds matrix dimensions. "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hkvm3t$i90$1(a)fred.mathworks.com>... > Or simply > > c = max(x,y)
From: Jan Simon on 10 Feb 2010 20:39 Dear Sean! > EDU>> x=1 > EDU>> y=2 > EDU>> max([x y]) > ??? Index exceeds matrix dimensions. You have shadowed the function "max" by a variable which is called "max" also. Solution: clear max max(x, y) It's recommended to avoid using function names a names of variables. Kind regards, Jan
|
Next
|
Last
Pages: 1 2 Prev: replace values in a cell with nan Next: Simulink Pulse Generator with amplitude between -1 and +1 |