Contour plot of a source which decays with radius.
Show older comments
So i am trying to create a contourf() plot of a source (representative of sound), whose output decays due to the attenuation of sound with radius. I expect the output to be contours of reducing magnitude around the centre point. They should be perfectly circular.
The decay is expressed by the function
10*log10(exp(2*alpha))*(distance from source)
where alpha is calculated earlier in the script. For all intents and purposes, it is just a constant (lets say 0.005).
As i understand i should create it in polar, convert to cartesian and then plot but i end up with linear contours, not circular. I am fairly new to matlab so its all a bit above my head. This is what i have currently:
--------------
radius = 0:1000; % the distance from source i want to evaluate
theta = (0:360)*pi/180; % the polar circle in radians
[th,r] = meshgrid(theta,radius); % create a meshgrid??? this step i'm unsure of and only using due to other answers on similar topics
[TH,R] = pol2cart(th,r); %convert to cartesian
A = 10*log10(exp(2*alpha))*R; %define the function for decay of sound
figure(2)
contourf(X,Y,A) % plot. is this right?
colorbar
axis square
-----------
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Sep 2017
A = 10*log10(exp(2*alpha))*y;
I would recommend renaming your x and y to TH and R or the like.
1 Comment
Calum Harrison
on 29 Sep 2017
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!