How to resolve the error-Input arguments of type 'double'?.

I tried to perform double integration using syms function in my program. Its generating the error- Input arguments of type 'double. What could be the possible mistake?
The expression is :
delF=((-h^2)/rad)*sigma*(rad^2)*(2*pi)*omega*square(abs((R2*exp((alpha/rad)*z))+(S2*exp((-alpha/rad)*z))))**
Here h is the harmonic order which assumes its value for every iteration (from an outer for loop).
omega and sigma are constants.
R2,S2 and alpha are parameters which are calculated during the iteration process
Its a 2D cylindrical coordinate system analysis with the given expression integrated over radius (rad) and z
The limits of integration for rad-inner radius (Rin) and outer radius (Rout)(Rin and Rout are taken as inputs) z-g to (g+e) (g and e are also taken as inputs)
my code is:
syms rad z
firstans=int(((-sigma*(h^2)/rad)*(2*pi)*omega*(rad^2))*(square(abs((((R2*exp((alpha*z/rad))+(((S2*exp((-alpha*z/rad))))))))))),rad,Rin,Rout);
answer=int(firstans,z,g,g+e);
[Merged information from duplicate question]
When I tried to perform double integration it is generating an error "input arguments should be of type double". I used syms command. How do I check if the parameters of my function are of type 'double'

12 件のコメント

Matt Fig
Matt Fig 2012 年 9 月 26 日
You know that it always help to show the actual code, so please do so.
Subhashree rajagopal
Subhashree rajagopal 2012 年 9 月 28 日
編集済み: Subhashree rajagopal 2012 年 9 月 28 日
ya thanks for your interest...pl see if my editted question is enough.
Walter Roberson
Walter Roberson 2012 年 9 月 28 日
Which line is the error being generated on? Please show the error trace.
Use the debugger to stop at that line and examine the arguments.
Subhashree rajagopal
Subhashree rajagopal 2012 年 9 月 28 日
@Walter Roberson:The error is generated in the line after syms rad z.its line no.79 of my code the error is: Input arguments should be of type 'double'
Walter Roberson
Walter Roberson 2012 年 9 月 28 日
So the problem is not the double integration, it happens even on the first integration ?
Subhashree rajagopal
Subhashree rajagopal 2012 年 9 月 29 日
@Walter Roberson: Yes exact. Iam doing the Matlab coding for the first time. So please help.
Walter Roberson
Walter Roberson 2012 年 9 月 29 日
As I wrote before, "Use the debugger to stop at that line and examine the arguments."
Subhashree rajagopal
Subhashree rajagopal 2012 年 10 月 4 日
the error resolved... thanks for the reply and sorry for the inconvinience.
Walter Roberson
Walter Roberson 2012 年 10 月 4 日
What did you determine the cause to be?
Subhashree rajagopal
Subhashree rajagopal 2012 年 10 月 4 日
Its actually an absurd mistake that I have to admit.As you can see in the expression above instead of squaring the absolute value of the expression inside I used square which generates a square wave.Using the debugger I could realise the error. And,one more thing, since my code involves the calculation of the integral for several iterations the symbolic calculation of the integral as done above is really a time consuming process.So I used the numerical evaluation-dblquad function instead.Within no time I could obtain my results.And,here too debugger helped me a lot.It indicated the details of each and every parameter and using that I could sort out the errors within no time.
Subhashree rajagopal
Subhashree rajagopal 2012 年 10 月 4 日
And Iam sorry for using "need faster reply" before.Sorry for the inconvinience.The answers and comments you post are very useful to beginners like me.Thanks a lot!!
Walter Roberson
Walter Roberson 2012 年 10 月 4 日
oooo... I missed seeing the square() call. Good hunting there.

サインインしてコメントする。

回答 (1 件)

Muruganandham Subramanian
Muruganandham Subramanian 2012 年 9 月 28 日
編集済み: Walter Roberson 2012 年 9 月 28 日

0 投票

Hi,
Before doing that integration using 'syms' command. better you convert all the variables by using double('var') or other commands like single(' '); , etc...Then try it.

1 件のコメント

Walter Roberson
Walter Roberson 2012 年 9 月 28 日
Probably not. int() is symbolic integration, and if all the variables are floating point, there will not be anything useful to integrate.

サインインしてコメントする。

タグ

質問済み:

2012 年 9 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by