getting error "unable to convert expression in to double array" while using int for symbolic expressions.

5 次查看(过去 30 天)
I am calculating this integration but finding error.
The expression for the refrence is following:
OS = int((int((beta.*(1./sqrt(2.*pi)).*besselj(1,(3.8317)*R)),R)),R,[0,10e-9])
beta is some finite constant.
  1 个评论
Walter Roberson
Walter Roberson 2023-9-15
syms beta R
OS = int((int((beta.*(1./sqrt(2.*pi)).*besselj(1,(3.8317)*R)),R)),R,[0,10e-9])
OS = 
vpa(OS)
ans = 
If beta were a symbolic variable at that point then double(OS) would fail because double() would not be able to convert the symbolic variable that had no definition. But if beta had a specific numeric value before the calculation was run, then double() should be able to process it.

请先登录,再进行评论。

回答(1 个)

Chetan
Chetan 2023-9-15
编辑:Chetan 2023-9-15
Hello @pooja sudha,
It seems that you are encountering an issue while working with symbolic variables and receiving an error.
To perform symbolic integration, you need to utilize the "int" function from the Symbolic Math Toolbox.
Here's an example of how you can perform symbolic integration for the expression you provided:
syms R beta
OS = int(int(beta*(1/sqrt(2*pi))*besselj(1,3.8317*R), R), R, [0, 10e-9]);
Make sure you have the Symbolic Math Toolbox installed and loaded in MATLAB to perform symbolic computations.
For more details about syms” function refer to the following article:
I hope these suggestions help you resolve the issue you are facing.
  1 个评论
Walter Roberson
Walter Roberson 2023-9-15
This error occurs because the "int" function in MATLAB is designed for numerical integration and cannot directly handle symbolic expressions.

Incorrect. There is no numeric integration function named int. int is only for sym and symfun and maybe symmatrix

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by