how to collect the coefficients of a matrix?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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 个评论
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 Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!