MATLAB: When using matlab, you can actually divide a scalar by column vector and produce a result; how does Matlab execute this

column vectorscalar vector division

I've been working on a solution to this and have gotten this far:
While matlab is looking for the greatest value to divide by, it is only looking for the first occurrence which is why it only prints a value once.
So you have a scalar: k divided by the column [a; b; c]. Matlab first checks if (a >= b) && (a >= c). If a is the largest value or equal to the other values, then it is used to divide and then its position (first) is used to index, and the rest of the values are 0. This is why when you divide 1 by [4; 4; 4], even though all the values are equal, it returns 0.25 0 0.
If the first condition is false, then matlab checks if b>=c. If b is larger than or equal to c, then it is used to divide and then its position (second) is used to index, and the rest of the values (first and third) are 0. So for example, if you divide 1 by [2; 4; 4], you will return 0 0.25 0.
If the first and second condition are false, then matlab knows that c is the greatest number and uses it to divide and uses its position as the index (so third). So for example, if you divide 1 by [2; 2; 4] you will return 0 0 .25.
This is obvious and logical but I'm skeptical if this is true. If it were true, how can you explain inf./[0;0;0] vs inf/[0;0;0]? The first works and the second gives a warning but proceeds and gives the answer 0 0 0. (The warning is "Warning: Rank deficient, rank = 0, tol = 0.000000e+00. "

Best Answer

The operation A/B is explained in the documentation: doc mrdivide. In your case A is a scalar and B a vector. This matches this case:
  • If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with n columns, then x = B/A returns a least-squares solution of the system of equations x*A = B.
So you get a least squares solution, see. e.g. https://en.wikipedia.org/wiki/Linear_least_squares_(mathematics) .
Related Question