How can i write this in Matlab?

1 回表示 (過去 30 日間)
Jane Smith
Jane Smith 2020 年 3 月 28 日
コメント済み: Walter Roberson 2020 年 3 月 28 日
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 28 日
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.

サインインしてコメントする。

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 3 月 28 日
編集済み: Ameer Hamza 2020 年 3 月 28 日
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);

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by