Find definite integrals for the expressions listed as the elements of a matrix

1 次查看(过去 30 天)
I have a matrix populated with symbolic expressions in 2 variables. I would like to carry out a definite surface integral of each expression and keep the results in the same matrix format. A dummy code below:
%Clear variables and cmd window
clear;
clc;
%Define symbolic variables
syms x y;
K_unintegrated = syms(zeros(2));
%Populate K_unintegrated matrix with expressions of 2 variables
K_unintegrated(1,1) = x^2;
K_unintegrated(1,2) = x*y;
K_unintegrated(2,1) = y*x;
K_unintegrated(2,2) = y^2;
%Display K_unintegrated matrix
K_unintegrated
%Attempt surface integral of each expression in the matrix (should
%hopefully give a fully numeric matrix)
K=int(int(K_unintegrated,x=0..2),y=0..2)
I get the following error:
Error: File: example.m Line: 20 Column: 27 The expression to the left of the equals sign is not a valid target for an assignment.
The Mathworks site gives the following info:
Find indefinite integrals for the expressions listed as the elements of a matrix: syms x t z alpha = sym('alpha'); int([exp(t), exp(alpha*t)]) The result is: ans = [ exp(t), exp(alpha*t)/alpha]
This is very much what I would like to do, except I want to evaluate the definite integral of each matrix element.
How can I achieve this in the most efficient way possible?

采纳的回答

Walter Roberson
Walter Roberson 2013-6-27
K=int(int(K_unintegrated,x,0,2),y,0,2)
The syntax you found is only within MuPAD

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by