how to collect the coefficients of a matrix?
Show older comments
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
Answers (1)
Azzi Abdelmalek
on 4 Oct 2013
Edited: Azzi Abdelmalek
on 4 Oct 2013
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 Comments
suvadip paul
on 4 Oct 2013
Azzi Abdelmalek
on 4 Oct 2013
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)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!