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

1 Ansicht (letzte 30 Tage)
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 Kommentar
Walter Roberson
Walter Roberson am 15 Sep. 2023
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Chetan
Chetan am 15 Sep. 2023
Bearbeitet: Chetan am 15 Sep. 2023
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 Kommentar
Walter Roberson
Walter Roberson am 15 Sep. 2023
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by