- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Yeah! Frist!
Let's catch all da frist exceptions!
Admin
Good old Pokemon exception handling.
Admin
I've had to write some Matlab code recently, and yeah.
Matlab has a few neat features. Many functions can operate on a scalar or array, and if you give it an array it will automagically apply the function to every element of the array. This feature would be a lot better if Matlab handled type annotations correctly, so that someone reading the code could see what the hell the code is doing or which of the hundred different slightly-incompatible kinds of arrays it's working with.
Admin
They aren't set to zero, they are set to not exist, and down the line something is supposed to barf with "No variable in scope". Which is a different kind of headache to debug.
Admin
Isn't this what LISP's
mapfamily of functions, and Python list comprehensions, do?Admin
Also, why does the catch clause set bigStruct to something... random?, but leave FileName and PathName alone, while the try clause does the opposite?
Admin
Just for the record, I am NOT that Carl W.
Admin
MATLAB: where the initiating seed for random() is by default set to the same value at the start of every session. Where functions will accept 1 xN vectors but not Nx1 vectors
Where the default for the "clear" aka rm or del, is >> clear all . Just what you'd want.
Admin
I don't see the problem, you need it to act that way so that it can be tested repeatedly.
/s
Admin
In Matlab,
structis your empty constructor. So it's not random, just empty.That doesn't answer "why", but...
Admin
Matlab is arcane because it's designed to work on matrices. You'd represent a vector as a matrix and then apply transformations to it via other matrices and mixing code and data gets very messy very quickly. (I was a whiz at it at the time and could autogenerate my entire homework from a Matlab script with all the graphs and such).
Though I used an ancient version they had students use. I think modern versions include a compiler to C and other stuff
Admin
Just to clarify a bit,
structthere calls the function namedstruct, even though it doesn't have parentheses (i.e.struct()) like most other languages require.Admin
Yes, but in Matlab you don't have to use a
mapfunction or anything similar (assuming you have one of the kinds of arrays where it works; see my earlier comment). You can just have something likefloor(array_of_floats)instead ofmap(floor, array_of_floats).Admin
That's not a WTF.
1 x nandn x 1are absolutely not the same thing.Edit Admin
Or more explictly, NxM and MxN matrices are completely different things. Just like multiplying two matrices is not commutative (AB is not the same as BA, and it's even possible that B*A cannot be performed).
There are various transforms you can apply to permute a 1xN to an Nx1 matrix or NxM to MxN.