create a matrix from a matrix x=[-2 -1 0 1 2]; which follow quadratic equations

1 回表示 (過去 30 日間)
Abinash Baral
Abinash Baral 2016 年 11 月 30 日
コメント済み: Abinash Baral 2016 年 11 月 30 日
Hi everyone, i want to create a matrix from this matrix x=[-2 -1 0 1 2] in such a way that resultant matrix is [ (-2^2),(-2^1),(-2^0); (-1^2),(-1^1),(-1^0); (0^2),(0^1),(0^0); (1^2),(1^1),(1^0); (2^2),2^1),(2^0) ]

採用された回答

Alexandra Harkai
Alexandra Harkai 2016 年 11 月 30 日
x = [-2:2];
y = [2:-1:0];
bsxfun(@power, x', y)
  3 件のコメント
Alexandra Harkai
Alexandra Harkai 2016 年 11 月 30 日
Very true.
Abinash Baral
Abinash Baral 2016 年 11 月 30 日
thank you all

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2016 年 11 月 30 日
編集済み: Andrei Bobrov 2016 年 11 月 30 日
x = [-2 -1 0 1 2];
out = x(:).^(2:-1:0); % for R2016b

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by