Effacer les filtres
Effacer les filtres

use x and y in a matrix

5 vues (au cours des 30 derniers jours)
Sa Moha
Sa Moha le 16 Déc 2021
I want calculate D(x,y) after running code.
clear;
clc;
syms x y;
E=cell(3,1);
E{1}=[1,1,1;1,2,0;3,5,2];
E{2}=[1,0,0;3,2,1;0,4,3];
E{3}=[0,1,1;0,2,1;2,6,1];
A=[1;5;7];
B=[2,3,4];
C(x)=A+x*B;
D(x,y)=E{y}*C;
D(1,2)
But it returns error. Can someone help please?
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic
variables, and function body must be sym expression.

Réponse acceptée

Steven Lord
Steven Lord le 16 Déc 2021
syms x y;
E=cell(3,1);
E{1}=[1,1,1;1,2,0;3,5,2];
E{2}=[1,0,0;3,2,1;0,4,3];
E{3}=[0,1,1;0,2,1;2,6,1];
A=[1;5;7];
B=[2,3,4];
C=A+x*B;
D = @(xin,y) subs(E{y}*C, x, xin);
D(1,2)
ans = 

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by