Asked by Osama Tabbakh
on 16 Oct 2019 at 10:23

Let's consider, A is a vector like shown:

A = [20 30 40];

and B is also a vector:

B = [5 10 20];

when you want to execute this operation:

C = B/A;

then you will get a scalar: 0.4137

if you want to check this answer by doing this:

C.*A

It should be got B again but you will get this vector instead:

ans =

8.2759 12.4138 16.5517

Could somebody explain what's going on?

Answer by Star Strider
on 16 Oct 2019 at 14:27

Accepted Answer

To expand slightly on that, ‘C’ is the least-squares estimate of the slope of with the y-intercept forced through the origin:

figure

plot(A,B,'p', A,C*A,'-r', [0 A(1)],C*[0 A(1)],':k')

axis([0 45 0 25])

Star Strider
on 17 Oct 2019 at 11:56

As always, my pleasure.

Calculating the slope alone is straightforward (β is the slope parameter):

Set this equal to zero and solve to get:

Osama Tabbakh
on 17 Oct 2019 at 13:28

Thanks!

Star Strider
on 17 Oct 2019 at 14:17

As always, my pleasure!

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## darova (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/485644-how-does-matlab-divide-two-row-vectors-by-each-other-to-get-a-scalar#comment_756838

## Adam (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/485644-how-does-matlab-divide-two-row-vectors-by-each-other-to-get-a-scalar#comment_756842

## Stephen Cobeldick (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/485644-how-does-matlab-divide-two-row-vectors-by-each-other-to-get-a-scalar#comment_756846

## Osama Tabbakh (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/485644-how-does-matlab-divide-two-row-vectors-by-each-other-to-get-a-scalar#comment_756883

Sign in to comment.