use x and y in a matrix

5 次查看(过去 30 天)
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.

采纳的回答

Steven Lord
Steven Lord 2021-12-16
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 = 

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by