Hello i wish to calculate the following integral
My difficulty stems from the absolute value which is "outside" of the integral with respect to θ

 Akzeptierte Antwort

Bruno Luong
Bruno Luong am 4 Aug. 2020
Bearbeitet: Bruno Luong am 4 Aug. 2020

0 Stimmen

Feel free to change these hyper-parameters
n = 3
k = 2*pi*rand()
integral(@(phi) arrayfun(@(phi) abs(integral(@(theta) exp(1i*k*cos(theta-phi)).*cos(n*theta), 0, 2*pi)).^2, phi), 0, 2*pi)

4 Kommentare

MINAS KOUROUMPLAKIS
MINAS KOUROUMPLAKIS am 4 Aug. 2020
Thank you for your reply, i get this error message
Error using subsindex
Function 'subsindex' is not defined for values of class 'function_handle'.
Error in sym/subsref (line 771)
R_tilde = builtin('subsref',L_tilde,Idx);
Bruno Luong
Bruno Luong am 4 Aug. 2020
Bearbeitet: Bruno Luong am 4 Aug. 2020
I proposed numerical method, not symbolic. You enter n and k as double numbers then it will work fine.
Can't hep you if you want symbolic integration; someone else might help you because I don't own symbolic tbx.
Matt J
Matt J am 4 Aug. 2020
Looks like a square .^2 is missing from the absolute value.
Bruno Luong
Bruno Luong am 4 Aug. 2020
Oh heah, thank you for spotting the error Matt. I'll fix it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Matt J
Matt J am 4 Aug. 2020
Bearbeitet: Matt J am 4 Aug. 2020

0 Stimmen

My difficulty stems from the absolute value which is "outside" of the integral
Why is this a difficulty? Because it prevents you from using integral2()? Just apply integral() twice instead.

5 Kommentare

MINAS KOUROUMPLAKIS
MINAS KOUROUMPLAKIS am 4 Aug. 2020
Can you please elaborate, i am ashamed to say that i don't see how i can do it without integral2()?
MINAS KOUROUMPLAKIS
MINAS KOUROUMPLAKIS am 4 Aug. 2020
Tried everything, nothing!
Matt J
Matt J am 4 Aug. 2020
Use integral() to evaluate the inner integral (over theta). Then take the absolute value squared of that. Then apply integral() again to integrate the result fo the previous step over phi.
MINAS KOUROUMPLAKIS
MINAS KOUROUMPLAKIS am 4 Aug. 2020
This is what i do and i get an error message
fun=@(x,y)exp(-1i*cos(x-y)).*cos(x)
fun = @(x,y)exp(-1i*cos(x-y)).*cos(x)
>> integral(@(x) f(x,y),0,2*pi)
Error using subsindex
Function 'subsindex' is not defined for values of class 'function_handle'.
Error in sym/subsref (line 771)
R_tilde = builtin('subsref',L_tilde,Idx);
Steven Lord
Steven Lord am 4 Aug. 2020
Write a function to compute the inner integral. This function should accept phi. One wrinkle here is that since the outer integral call is going to pass a vector of values into it as phi, your inner integral call will need to say that the function is ArrayValued.
Write a function that takes the absolute value of that inner integral function.
Write a function to compute the outer integral of the absolute value function.
If you try this and it doesn't work, show us the code you wrote and we may be able to offer some guidance.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by