フィルターのクリア

how to collect the coefficients of a matrix?

3 ビュー (過去 30 日間)
suvadip paul
suvadip paul 2013 年 10 月 4 日
コメント済み: Azzi Abdelmalek 2013 年 10 月 4 日
syms m
A=[6*m 2*m]
Then how to collect only the coefficients of m in A in a matrix, i.e., i need
ans= 6 2

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 4 日
編集済み: Azzi Abdelmalek 2013 年 10 月 4 日
syms m
A=[6*m 2*m]
for k=1:numel(A);
c(k)=coeffs(A(k));
end
disp(c)
% or
c=subs(A,1)
  2 件のコメント
suvadip paul
suvadip paul 2013 年 10 月 4 日
Thank you. How it should be modified if A is of the form A=[6*m+9 2*m 2]. I need the answer as ans=[6 2] or [6 2 0]
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 4 日
clear
syms m
A=[6*m+9 2*m 2];
for k=1:numel(A)
a=sym2poly(A(k));
if numel(a)>1
out(k)=a(1);
else
out(k)=0;
end
end
disp(out)

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

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by