[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
More MATLAB Silliness
From: |
John W. Eaton |
Subject: |
More MATLAB Silliness |
Date: |
Tue, 5 Oct 2004 16:33:52 -0400 |
On 29-Sep-2004, Quentin Spencer <address@hidden> wrote:
| For anyone tracking weird things that MATLAB lets you do that somebody
| might ask for in octave someday, how about this:
|
| >> a=ones(2,1);
| >> b(1,:)=ones(2,1);
| >> whos
| Name Size Bytes Class
|
| a 2x1 16 double array
| b 1x2 16 double array
|
| I'm always unintentionally doing things like this in my code (assign a
| column vector to a row of a matrix), and in the past both Octave and
| MATLAB would give you an error, and I would fix it. Release 14 appears
| to have changed this to automatically detect what you meant to do and
| take care of it for you. A nice thought, I suppose, but I wonder what
| unintended consequences this could cause for an unsuspecting user. Are
| there any reasons other than convenience why this behavior is good? Any
| guesses on how many releases until they remove this feature?
I suspect that this behavior is allowed because the orientation of
vectors is considered unimportant.
Should we copy this behavior?
The problem I see is that you can be tripped up if you are writing
code that is expected to work with matrices but only test your code
with matrices that have one row or column. Then it can appear that
your code is OK during testing and fail later when someone tries to
run the code with matrices that have rows and columns both greater
than 1.
jwe
- More MATLAB Silliness,
John W. Eaton <=