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일

0 개 추천

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]
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)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2013년 10월 4일

댓글:

2013년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by