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