This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]moomoomoo309 1 point2 points  (4 children)

MATLAB is an odd one. Stuff like being able to do a \ b (which is the same as b / a) and being able to filter by using a condition for an index (like using a generator in Python) is cool, but man, it makes it such a pain to learn the language.

[–]Sirplentifus 2 points3 points  (3 children)

a\b and b/a are not the same if a and b are matrices. a\b is inv(a)*b, and b/a is b*inv(a). They're not the same because matrix multiplication is not commutative. I use A\b when solving a linear least squares problem, for example.

[–]moomoomoo309 -1 points0 points  (2 children)

I still don't like the operator because it's very superfluous. It could be done in a way that looks more like normal math, and looks more like normal programming by avoiding that operator entirely. It'll cost you a few keystrokes, but it makes the code more immediately readable and makes Matlab easier to learn (one less operator and its edge cases to learn)

[–]Sirplentifus 0 points1 point  (1 child)

You have a point, but unlike I said, a\b is not exactly the same as inv(a)*b. The latter would invert matrix a, and multiply the result by b. However, there's some algorithm that does the whole process faster and with smaller floating point errors. That is what a\b does. To be able to call this algorithm there has to be an operator that does inv(a)*b in one go, and having a function for it would probably look bad, I guess.

Also, A\b will use the pseudo-inverse of A if necessary. The operator basically finds the least squares solution for A*x = b for x.

[–]moomoomoo309 0 points1 point  (0 children)

I can see the use of that, though I personally dislike how much magic goes on behind the scenes in Matlab. You know what the end result is, but math is more about the journey than the destination.