calculate the matrix when there are x and y as variables

조회 수: 4 (최근 30일)
Yossi Mendel
Yossi Mendel 2025년 4월 29일
댓글: Torsten 2025년 4월 29일
Assuming i have a matrix that looks like that :
A=[3*x^2+5*y+7 6*x+y^3 ; x^3-7*y 1/y+4*x-5]
If x=3 and y=1
how can i calculate the value of matrix A ?
I have a license to symbolic
Appreciate support
thanks in advance
Yossi

채택된 답변

Voss
Voss 2025년 4월 29일
You have it already:
x=3;
y=1;
A=[3*x^2+5*y+7 6*x+y^3 ; x^3-7*y 1/y+4*x-5]
A = 2×2
39 19 20 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Or, if you want to use the Symbolic Math Toolbox:
syms x y
A=[3*x^2+5*y+7 6*x+y^3 ; x^3-7*y 1/y+4*x-5]
A = 
result = subs(A,[x,y],[3,1])
result = 
  댓글 수: 1
Torsten
Torsten 2025년 4월 29일
Or define A as a function:
A = @(x,y)[3*x^2+5*y+7 6*x+y^3 ; x^3-7*y 1/y+4*x-5];
A(3,1)
ans = 2×2
39 19 20 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

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

추가 답변 (0개)

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by