How can i write this in Matlab?

1 Kommentar

Walter Roberson
Walter Roberson am 28 Mär. 2020
The summation can be split to and each of those Σ can be translated into a sum() call.
With a small bit of cleverness you can also replace two of the sums with var() calls.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ameer Hamza
Ameer Hamza am 28 Mär. 2020
Bearbeitet: Ameer Hamza am 28 Mär. 2020

0 Stimmen

If x and y are 1D vectors then try something like this.
x = rand(100, 1);
y = rand(100, 1);
x_bar = mean(x);
y_bar = mean(y);
b_hat = sum(x-x_bar)*sum(y-y_bar)/sum((x-x_bar).^2);

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Mär. 2020

Kommentiert:

am 28 Mär. 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by