From: wendy on 3 Feb 2010 10:19 Is there a percent change function built-in for Matlab? or do I have to create the function manually? Thank you
From: ImageAnalyst on 3 Feb 2010 10:40 On Feb 3, 10:19 am, "wendy " <mak...(a)hotmail.com> wrote: > Is there a percent change function built-in for Matlab? or do I have to create the function manually? Thank you Isn't it just percentChange = 100.0 * (newValue / referenceValue - 1); What were you thinking of?
From: Walter Roberson on 3 Feb 2010 12:27 ImageAnalyst wrote: > On Feb 3, 10:19 am, "wendy " <mak...(a)hotmail.com> wrote: >> Is there a percent change function built-in for Matlab? or do I have to create the function manually? > Isn't it just > percentChange = 100.0 * (newValue / referenceValue - 1); Hmmm, I wonder how we should define the result if the referenceValue is zero? Also, what if the two values are not floating point? For example, if the two values are uint8, perhaps 66 and 100, then the division would yield uint8 0, subtracting 1 would saturate to uint8 0, multiplying by 100.00 would yield either 0.0 or uint8 0 (I'd have to test which); but for int8 the result would be either -100.00 or int8 -100 (I'd have to test). Expanding the parenthesis would yield different values for those types. Perhaps it would make sense to cast the values to double and then cast the result to the type of the arguments (I seem to recall that Matlab usually uses the smallest type in such cases.)
|
Pages: 1 Prev: ilaplace Next: Embedded Matlab Dynamic Matrix Allocation |