フィルターのクリア

Fitting vector of n length

2 ビュー (過去 30 日間)
Andreas Volden
Andreas Volden 2014 年 11 月 30 日
コメント済み: Andreas Volden 2014 年 11 月 30 日
Hi!
I'm trying to solve a problem involving a least square estimate. When defining input I try to fit my input vector to a following vector, phi which I use in the least square algorithm. My input vector, A, is simply [1xn].
My phi vector looks like this:
[ u(1)^2, u(1), 1;
u(2)^2, u(2), 1;
. .
. .
u(n-1)^2, u(n-1), 1;
u(n)^2, u(n), 1];
Is there an easy and quick way to populate my phi vector using corresponding elements from A, as illustrated?
Thanks!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 11 月 30 日
編集済み: Azzi Abdelmalek 2014 年 11 月 30 日
u=[1 2 3 4 5 6 7 8 9 10]'
n=numel(u)
x=u(1:n);
phi=[x.^2 x ones(n,1)]
%or
phi=bsxfun(@power, repmat(u(1:n),1,3),2:-1:0)
  1 件のコメント
Andreas Volden
Andreas Volden 2014 年 11 月 30 日
Spot on. Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by