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
———–
Best Answer