필터 지우기
필터 지우기

Change a variable's value wherever exists

조회 수: 1 (최근 30일)
Vasilis Chasiotis
Vasilis Chasiotis 2020년 4월 22일
댓글: Deepak Gupta 2020년 4월 22일
I have the following code:
syms a
x = a+1;
a = 2;
However, the value of x is equal to a+1.
Because I put a=2, how can I take the output of x to be equal to 2+1=3?
Thanks

채택된 답변

Deepak Gupta
Deepak Gupta 2020년 4월 22일
Hello Vasilis,
You need to use subs function to calculate value of symbolic function.
subs(x) as last line will give you value of x for a = 2.
Thanks,
Deepal\k
  댓글 수: 2
Vasilis Chasiotis
Vasilis Chasiotis 2020년 4월 22일
It works! Thanks!
Deepak Gupta
Deepak Gupta 2020년 4월 22일
Welcome Vasilis.
Please mark the answer as accepted if this solves your problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Variables, Expressions, Functions, and Preferences에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by