Hi, i need help.
how can I multplying matrices 1x3 with 3x1 with variable only for it element.
as example, I want to multiply [1 2 3 4 5] with [x^0 x^n-4 x^n-3 x^n-2 x^n-1]
I have done it with fliplr and poly2sym, but, is there any way without using poly2sym at all?

 採用された回答

David Hill
David Hill 2020 年 9 月 5 日

0 投票

syms x n;
a=[1,2,3,4,5];
b=[x; x^n-4; x^n-3; x^n-2; x^n-1];
c=a*b;

4 件のコメント

Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020 年 9 月 5 日
is there a way so the B matrix is automatically fill with x^0:x^n-1?
David Hill
David Hill 2020 年 9 月 5 日
編集済み: David Hill 2020 年 9 月 5 日
a=5:-1:1;
syms x;
b=sum(a.*(repmat([x],1,length(a)).^(0:4)));
Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020 年 9 月 6 日
thank you for your help!
I am asking your permission to update a little so it works on my function.
David Hill
David Hill 2020 年 9 月 6 日
Yes

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

その他の回答 (1 件)

Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020 年 9 月 5 日

0 投票

Okay, I think I have misleading with the question, what I am trying to do is to create a function which result is an equation. if input isA= [5 4 3 2 1], then the result is 5+4x^2+3x^3+2x^4+x^5. first thing that came to my mind is, to create a matrix multiplying, A and its x matrix. am I on the right way?

2 件のコメント

David Hill
David Hill 2020 年 9 月 5 日
You must mean 5+4*x+3*x^2+2*x^3+x^4. Why not just use charateristic polynomial functions?
Yanuar Rizki Pahlevi
Yanuar Rizki Pahlevi 2020 年 9 月 5 日
Oh, yes sorry I mistyped that. Yes, I can perform it using characteristic polynomial function and with help of fliplr.
But, I am trying not use any built in polynomial at all..
I have trying using FOR loops, but the result is not what I meant to be. the result is 15+15x+15x2+15x3+15x4. it is wrong but it feels I am close to my goal

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

カテゴリ

ヘルプ センター および File ExchangePolynomials についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by