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
  1 件のコメント
Kobye
Kobye 2013 年 6 月 27 日
Excellent answer, solved my query straight away!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by