junoexpress <MTBrenneman@gmail.com> wrote in news:cab4169a-2112-470d-afba-
4c27a5858cca@8g2000hse.googlegroups.com:
> but I'd like to make certain there are not cases/
> circumstances where using it would cause me problems.
It doesn't seem much different to producing a long result when adding a
short to a long. In the example you cite, adding a vector to a scalar,
what would you prefer, an error?
Matlab will usually treat most operations as if they are operations on
whole arrays, and you will get an error when array sizes don't match.
Scalars will be automatically be expanded to arrays of the appropriate size
for the operation when it makes no sense to perform the operation on a
scalar and an array.
As to whether this causes you problems, it rarely, but not never, causes
issues for me. Without a description of what you do, it would be hard to
say how it will impact you.

Signature
Scott
Reverse name to reply
Titus - 22 Jul 2008 20:27 GMT
> junoexpress <MTBrenneman@gmail.com> wrote in news:cab4169a-2112-470d-afba-
> 4c27a5858cca@8g2000hse.googlegroups.com:
[quoted text clipped - 16 lines]
> issues for me. Without a description of what you do, it would be hard to
> say how it will impact you.
Hi,
in addition: open the doc and search for "scalar expansion". The first hit
describes this (and similar topics) in detail.
Titus
junoexpress - 23 Jul 2008 05:40 GMT
> Hi,
> in addition: open the doc and search for "scalar expansion". The first hit
> describes this (and similar topics) in detail.
>
> Titus
That explains my question exactly, and moreover, addresses my concern
that this is a built in inherent feature of MatLab rather than
something you can get away with due to some loophole in the program.
Thank you,
Matt
Scott Seidman - 23 Jul 2008 13:35 GMT
>> Hi,
>> in addition: open the doc and search for "scalar expansion". The
[quoted text clipped - 9 lines]
>
> Matt
There will always be some scalar/vector/array issues that pop up. One bit
me once, and its a fair illustrative example. I have an array where rows
are data for an experiment. I toss out rows that don't meet certain
criteria, and then use "mean". If there is more than one row, mean returns
the mean of each colum, but if there is only one row, mean returns the mean
of that row.

Signature
Scott
Reverse name to reply
Steven Lord - 23 Jul 2008 15:05 GMT
>>> Hi,
>>> in addition: open the doc and search for "scalar expansion". The
[quoted text clipped - 18 lines]
> mean
> of that row.
That's true. One way to avoid that issue is to explicitly specify the
dimension over which you want the computations performed; many of the data
functions (including MEAN) allow you to do so.
x = rand(1, 10);
m0 = mean(x); % scalar -- the mean of the row
m1 = mean(x, 1); % vector -- the mean of each column

Signature
Steve Lord
slord@mathworks.com