calculate the matrix when there are x and y as variables

5 vues (au cours des 30 derniers jours)
Yossi Mendel
Yossi Mendel le 29 Avr 2025
Commenté : Torsten le 29 Avr 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

Réponse acceptée

Voss
Voss le 29 Avr 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 commentaire
Torsten
Torsten le 29 Avr 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>

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by