symbolic Integration results showing large unsolved values with a function multiplied on which integration has been done

2 次查看(过去 30 天)
symbolic Integration results showing large unsolved values multiplied with a function on which integration has been done.how can one obtain matrix after symbolic numerical integration without symbolic representation of matrix elements.
  1 个评论
Walter Roberson
Walter Roberson 2022-2-24
Could you give us an example, and an more detailed description of what you would like to have happen instead?
.. Are you just looking for vpa() to convert rational values to floating point?

请先登录,再进行评论。

回答(1 个)

Shivam
Shivam 2024-1-12
Hi Subho,
Based on the information you shared, I understand that while dealing with symbolic integration in MATLAB, it results in large unresolved expressions and you want to perform numerical integration on a matrix without retaining the symbolic representation of the matrix elements.
You can utilize MATLAB's 'vpaintegral' and 'integral' functions to achieve the desired numerical integration on a matrix. You can follow the below workaround for a 1x2 matrix with integration limits from 0 to pi/2:
% Define the symbolic variable
syms x;
% Define the functions in a cell array/matrix
f = {sin(x) * exp(-x), sin(-x) * exp(x)}
f = 1×2 cell array
{[exp(-x)*sin(x)]} {[-exp(x)*sin(x)]}
% Define integration limits
a = 0;
b = pi/2;
% Numerical integration using vpaintegral for symbolic expressions
vpaIntMat = {vpaintegral(f{1}, a, b), vpaintegral(f{2}, a, b)}
vpaIntMat = 1×2 cell array
{[0.39606]} {[-2.90524]}
% Convert symbolic expressions to MATLAB functions
F = {matlabFunction(f{1}), matlabFunction(f{2})}
F = 1×2 cell array
{@(x)exp(-x).*sin(x)} {@(x)-exp(x).*sin(x)}
% Numerical integration using integral for MATLAB functions
intMat = {integral(F{1}, a, b), integral(F{2}, a, b)}
intMat = 1×2 cell array
{[0.3961]} {[-2.9052]}
You can refer to the following documentation links to know more about the 'vpaintegral' and 'integral' functions, as well as methods for integrating without using symbolic representation:
I hope it helps.
Thanks

产品

Community Treasure Hunt

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

Start Hunting!

Translated by