http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261
MATLAB Central Newsreader  numerical integration from data in cylindrical coordinates
Feed for thread: numerical integration from data in cylindrical coordinates
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Wed, 06 Oct 2010 17:45:26 +0000
numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#785676
Neal Lafferty
I have a 2d array of data 402 x 402 in the shape of (approximately) an airy disk that I need like to take the cumulative integral of. The data has radial symmetry, and I would like to plot the cumulative integral with respect to radius. cumtrapz only handles 1 dimension of integration at a time, and it is in cartesian coordinates.<br>
<br>
I want to numerically integrate from the center of the data (x=0,y=0) or r=0 outward, over theta=0 to 2pi, cumulatively. Can I do this in MATLAB? <br>
<br>
Thanks for any help that you might be able to offer.<br>
<br>
Neal

Wed, 06 Oct 2010 20:12:20 +0000
Re: numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#785719
Roger Stafford
"Neal Lafferty" <nxl7930@rit.edu> wrote in message <i8icjm$l55$1@fred.mathworks.com>...<br>
> I have a 2d array of data 402 x 402 in the shape of (approximately) an airy disk that I need like to take the cumulative integral of. The data has radial symmetry, and I would like to plot the cumulative integral with respect to radius. cumtrapz only handles 1 dimension of integration at a time, and it is in cartesian coordinates.<br>
> <br>
> I want to numerically integrate from the center of the data (x=0,y=0) or r=0 outward, over theta=0 to 2pi, cumulatively. Can I do this in MATLAB? <br>
> <br>
> Thanks for any help that you might be able to offer.<br>
> <br>
> Neal<br>
      <br>
You haven't made it clear what the points in your 402 x 402 array correspond to. Are they cartesian coordinates or polar coordinates? Also what quantity is being represented by the values at these array points? Are you attempting to find a double integral with respect to polar coordinates? Your mention of an Airy disk suggests that you are actually doing only a single integration. The long and short of my message is that I feel you need to rewrite your question in such a manner as to make it clear to us what you are actually asking.<br>
<br>
Roger Stafford

Wed, 06 Oct 2010 20:33:38 +0000
Re: numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#785725
Roger Stafford
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i8il74$ro0$1@fred.mathworks.com>...<br>
> You haven't made it clear what the points in your 402 x 402 array correspond to. Are they cartesian coordinates or polar coordinates? Also what quantity is being represented by the values at these array points? Are you attempting to find a double integral with respect to polar coordinates? Your mention of an Airy disk suggests that you are actually doing only a single integration. The long and short of my message is that I feel you need to rewrite your question in such a manner as to make it clear to us what you are actually asking.<br>
> <br>
> Roger Stafford<br>
        <br>
I failed to read your subject title carefully. Apparently your array of points correspond to radius r and distance z cylindrical coordinates, and you are attempted to find the numerical triple integral of some quantity that is constant with respect to theta, and which would therefore require only an appropriate double integration. Is that correct?<br>
<br>
Roger Stafford

Thu, 07 Oct 2010 13:16:03 +0000
Re: numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#785910
Neal Lafferty
> I failed to read your subject title carefully. Apparently your array of points correspond to radius r and distance z cylindrical coordinates, and you are attempted to find the numerical triple integral of some quantity that is constant with respect to theta, and which would therefore require only an appropriate double integration. Is that correct?<br>
> <br>
> Roger Stafford<br>
<br>
Roger,<br>
Thanks for taking a look and responding to my post. You are correct, I would like to perform a double integral (numerically) on my data. The problem is that now, using cumtrapz, I have to integrate over the columns first, and then rerun to integrate the rows. I'd like to have the data where I can take the cumulative integral over 0 to 2pi, and from r=0 to some radius. <br>
To better illustrate, my data resembles <a href="http://en.wikipedia.org/wiki/File">http://en.wikipedia.org/wiki/File</a>:Airypattern.svg when plotted with imagesc.<br>
I'd like to plot the cumulative volume under the curve with respect to radius, over 360 degrees. Graphically, it would resemble <a href="http://en.wikipedia.org/wiki/File">http://en.wikipedia.org/wiki/File</a>:Airy_Pattern_Intensity_and_Encircled_Power.svg<br>
So in short I want to numrically integrate an array that has rows/columns (cartesian) data in cylindrical coordinates. Is that possible in MATLAB?<br>
<br>
Thanks for the responses! I hope I could clarify.

Tue, 19 Oct 2010 02:40:05 +0000
Re: numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#788838
Neal Lafferty
I was able to solve my problem in a satisfactory way. I wanted to post it in case someone else is searching for a solution to this problem.<br>
The data I wanted to numerically integrate was from a 402x402 matrix generated from an external program. Based on <a href="http://www.mathworks.com/support/solutions/en/data/11679J/index.html?solution=11679J">http://www.mathworks.com/support/solutions/en/data/11679J/index.html?solution=11679J</a> , I decided to use trapz(trapz(data) to perform the double integration. However, I wanted to get the encircled volume as a function of the radius of a circle. Here is my solution:<br>
r = linspace(0,max(x),length(x)/2); % The vector of values of r to integrate<br>
<br>
% Preallocate for speed<br>
rVolume = zeros(size(r)); % This will store the volumes for each r<br>
<br>
% For each element in rVolume, create a filter function that is zero outside<br>
% of the radius of interest. Then multiply the original data by the filter before<br>
% integration. This way, the data can be easily integrated over the cylindrical<br>
% region of interest.<br>
for i=1:length(r)<br>
% Create a filter for the original data<br>
filter = sqrt(X.^2+Y.^2) <= r(i); % The filter is 1 inside radius, 0 outside<br>
% imagesc(x,y,filter);<br>
rVolume(i)=trapz(x,trapz(y,normData.*filter));<br>
end<br>
<br>
% Plot the cumulative integrated area vs radius<br>
plot(r,rVolume);

Wed, 29 Jan 2014 18:25:57 +0000
Re: numerical integration from data in cylindrical coordinates
http://www.mathworks.com/matlabcentral/newsreader/view_thread/293261#917138
victoriacurto1@gmail.com
Neal,<br>
<br>
I know your post is quite old but I am having the same problem you encountered for calculating the cylindrical volume under a surface. I'm looking at your code but I'm not sure what you mean by normData?<br>
<br>
<br>
<br>
On Tuesday, October 19, 2010 4:40:05 AM UTC+2, Neal Lafferty wrote:<br>
> I was able to solve my problem in a satisfactory way. I wanted to post it in case someone else is searching for a solution to this problem.<br>
> The data I wanted to numerically integrate was from a 402x402 matrix generated from an external program. Based on <a href="http://www.mathworks.com/support/solutions/en/data/11679J/index.html?solution=11679J">http://www.mathworks.com/support/solutions/en/data/11679J/index.html?solution=11679J</a> , I decided to use trapz(trapz(data) to perform the double integration. However, I wanted to get the encircled volume as a function of the radius of a circle. Here is my solution:<br>
> r = linspace(0,max(x),length(x)/2); % The vector of values of r to integrate<br>
> <br>
> % Preallocate for speed<br>
> rVolume = zeros(size(r)); % This will store the volumes for each r<br>
> <br>
> % For each element in rVolume, create a filter function that is zero outside<br>
> % of the radius of interest. Then multiply the original data by the filter before<br>
> % integration. This way, the data can be easily integrated over the cylindrical<br>
> % region of interest.<br>
> for i=1:length(r)<br>
> % Create a filter for the original data<br>
> filter = sqrt(X.^2+Y.^2) <= r(i); % The filter is 1 inside radius, 0 outside<br>
> % imagesc(x,y,filter);<br>
> rVolume(i)=trapz(x,trapz(y,normData.*filter));<br>
> end<br>
> <br>
> % Plot the cumulative integrated area vs radius<br>
> plot(r,rVolume);