how to use the subs syntax for the two variable

조회 수: 5 (최근 30일)
yogeshwari patel
yogeshwari patel 2023년 6월 9일
답변: yogeshwari patel 2023년 6월 9일
syms x a
series1(x) = a+(2/3)*a*x+(5/3)*a^2*x^2+(1/3)*a^3*x^3
a=0.56
series2(x)=subs(series1,a,0.56)
%%%%%%%%%%%%%%%%%%%%%%%
when is use the subs synatx to replace the value of a in series1 it is not replacing the vlue of a .
So what the problem with the synatx?
Since series1 is the function of x only so it is not replacing the value a ?
If yes how should I substuite the value of a so that series1 contain only variable x .

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 6월 9일
편집: Dyuman Joshi 2023년 6월 9일
"when is use the subs synatx to replace the value of a in series1 it is not replacing the vlue of a ."
When you define a=0.56, it overwrites a from symbolic variable to a double variable and thus you can not use it in subs()
There is no need of the line a=0.56. You can directly substitute the value.
In case you want to use a variable to store the value and then substitute, do not name it the same as the symbolic variable, use a different name such as - A or a0 or a_0 etc.
syms x a
series1(x) = a+(2/3)*a*x+(5/3)*a^2*x^2+(1/3)*a^3*x^3
series1(x) = 
series2(x)=subs(series1,a,0.56)
series2(x) = 

추가 답변 (1개)

yogeshwari patel
yogeshwari patel 2023년 6월 9일
Thank you

카테고리

Help CenterFile Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by