About variables and equations

조회 수: 1 (최근 30일)
shreekanteshwara M S
shreekanteshwara M S 2022년 6월 18일
답변: Karan Kannoujiya 2022년 6월 18일
Why is my variable not updating with an its answer?
For Example:
If write a= 6;
A=a^2;
A
I get 36 which is right.
Now if I give a=5;
A
I still get 36!
Should not the value of A be 25?
Should I re write A=a^2; before giving A after updating the value of a?

채택된 답변

Karan Kannoujiya
Karan Kannoujiya 2022년 6월 18일
Hello shreekanteshwara,
so your workflow is->
a=6;
A=a^2;
now the value of 'A' would be 36
Now you updated a to 5
a=5;
Value inside 'a' is 5
but the value of 'A' would still be 36 because you have updated 'a' only not 'A'
if you want value of A to be 25 then you have to rewrite the statement A=a^2
so the answer to your question-->
Should I re write A=a^2; before giving A after updating the value of a?
-->Yes you have to rewrite

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by