From: Peter Perkins on
On 7/17/2010 9:08 AM, Mayi DA wrote:
> As you know, 1*[] get []

1*[] is interpreted as follows: "1 is a 1x1 array, and [] is a 0x0
array. Their sizes don't match, but since 1 is a scalar, scalar
expansion is applied. Expand out the scalar 1 to the size of the 0x0
array [], and multiply elementwise. Since [] is 0x0, 1 gets expanded
out to ones(0,0), and the elementwise result is a 0x0 array."

> Let's see what will gain when Nan*[]? The answer that MATLAB gives is [].
> Can anyone give me an explanation?

Apply the above steps. The result [] is the only thing that makes sense
given the rules.

NaN is a 1x1 array containing the value NaN. It is true that "the value
NaN times any other value is NaN", and therefore every element in the
result of NaN*[] is NaN. However, the rules that govern the sizes of
array multiplication dictate that the result _has_ no elements.