【发布时间】:2017-09-13 08:39:39
【问题描述】:
我有两个函数列表,例如:log(n*x)、n=1:2017 和 cos(m*x)、m=1:6。我想要/需要构造这些向量的矩阵乘积,然后在 10 到 20 之间整合矩阵的每个元素。
我读过这篇文章: Matrix of symbolic functions 但我认为这对这个问题没有用。 我试图通过使用循环来做到这一点,但我无法得到它。
提前感谢您的阅读。
【问题讨论】:
我有两个函数列表,例如:log(n*x)、n=1:2017 和 cos(m*x)、m=1:6。我想要/需要构造这些向量的矩阵乘积,然后在 10 到 20 之间整合矩阵的每个元素。
我读过这篇文章: Matrix of symbolic functions 但我认为这对这个问题没有用。 我试图通过使用循环来做到这一点,但我无法得到它。
提前感谢您的阅读。
【问题讨论】:
您可以通过将适当的向量分配给n 和m 来解决此问题,如下所示:
n = (1:2017)'; % column vector
m = 1:6; % row vector
syms x;
l = log(n*x); % column vector of logs
c = cos(m*x); % row vector of cos
product = l*c; % matrix product
i = int(product, x, 10, 20); % integral from 10 to 20
iDouble = double(i); % convert the result to double
【讨论】: