From: Ulrik Nash on 27 Apr 2010 08:10 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.
From: Bruno Luong on 27 Apr 2010 08:43 "Ulrik Nash" <uwn(a)sam.sdu.dk> wrote in message <hr6k6v$lr8$1(a)fred.mathworks.com>... > 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
From: Ulrik Nash on 27 Apr 2010 10:03 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
From: Matt Fig on 27 Apr 2010 10:51 "Ulrik Nash" <uwn(a)sam.sdu.dk> wrote in message <hr6qqo$eg$1(a)fred.mathworks.com>... > 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.
|
Pages: 1 Prev: Convert image coordinates to world coordiantes Next: question about crosscorr |