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

조회 수: 1 (최근 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