MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Thread Subject: max value of two expressions

 Subject: max value of two expressions From: Ulrik Nash Date: 27 Apr, 2010 12:10:07 Message: 1 of 4 Hi Everyone, Suppose I have two expressions A = B + C and D = E + F Now I simply wish to let G take the value A or D, depending on which of A or D is largest. If A > D, then G = A, and if A < D, then G = D. How can I do this in a simple expression without using if then? Cheers Ulrik.
 Subject: max value of two expressions From: Bruno Luong Date: 27 Apr, 2010 12:43:04 Message: 2 of 4 "Ulrik Nash" wrote in message ... > Hi Everyone, > > Suppose I have two expressions > > A = B + C > > and > > D = E + F > > Now I simply wish to let G take the value A or D, depending on which of A or D is largest. If A > D, then G = A, and if A < D, then G = D. > > How can I do this in a simple expression without using if then? The simplest is max(A,D) Bruno
 Subject: max value of two expressions From: Ulrik Nash Date: 27 Apr, 2010 14:03:04 Message: 3 of 4 Thanks Bruno, When I use the command on my expressions, I get an error message: "Undefined function or method 'max' for input arguments of type 'struct'." Why do i get this message? Cheers
 Subject: max value of two expressions From: Matt Fig Date: 27 Apr, 2010 14:51:04 Message: 4 of 4 "Ulrik Nash" wrote in message ... > Thanks Bruno, > > When I use the command on my expressions, I get an error message: > > "Undefined function or method 'max' for input arguments of type 'struct'." > > Why do i get this message? > > Cheers Well, why *wouldn't* you get that message? A.food = 'orange'; A.spice = 'nutmeg'; B.food = 'potato'; B.spice = 'clove'; Now, which structure is bigger? Think about it please.