calculate the matrix when there are x and y as variables

3 Ansichten (letzte 30 Tage)
Yossi Mendel
Yossi Mendel am 29 Apr. 2025
Kommentiert: Torsten am 29 Apr. 2025
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

Akzeptierte Antwort

Voss
Voss am 29 Apr. 2025
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 Kommentar
Torsten
Torsten am 29 Apr. 2025
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>

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by