how can i extract the symbolic variable from a symbolic vector or matrix

조회 수: 4 (최근 30일)
reza sol
reza sol 2017년 12월 5일
편집: M 2017년 12월 5일
I have a vector like something in attach file f0 and L was defined as two symbolic parameters. I want these parameters be like vector coefficient for [1/6;2/3;1/6] Thanks in advance

채택된 답변

M
M 2017년 12월 5일
syms f0 L
r=f0*L*[1/6;2/3;1/6];
r =
(L*f0)/6
(2*L*f0)/3
(L*f0)/6
and
var=symvar(r)
var =
[ L, f0]
  댓글 수: 2
reza sol
reza sol 2017년 12월 5일
Appreciate your quick answer.Another thing i would like to get access to actually is that numeric data as a vector .Imagine you have a huge size matrix and you have all these F0*L in it.I need a function or any manipulation Technic to have both symbolic vector and numeric data matrix separately
M
M 2017년 12월 5일
편집: M 2017년 12월 5일
Not sure if it is the best way but you can try something like this :
syms f0 L
num=[1/6;2/3;1/6];
r=f0*L*num;
symbolicVariables=symvar(r)
symbolicVariables =
[ L, f0]
numericPart=zeros(length(r),1);
for i=1:length(r)
numericPart(i)=coeffs(r(i));
end
numericPart =
0.1667
0.6667
0.1667

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by