Adding z-values for surf/contour plots - PART II

Helloo! Even though Matt made an excellent answer to PART I of our problem, we can't really make it work in the end.
As for now Z represents already defined levels/values, dependent upon the radius from the source's origin. When two sources interfere, the values of Z in that particular area should be added in some way. Exactly as you intepreted it Matt! Though, lets say we skip that cone of ours - and focus upon a much weirder shape. Like this. Its here we're failing in math I think..
X=sin(t)'.*sin(t)'.^2*r+dx;
Y=cos(t)'.*sin(t)'.^2*r+dy;
Where dy and dx only is the translation of the position of the source from origo and 0 < t < 2pi. The radius r is a vector. Z is a vector/matrix with values depending upon r, as said.
Though your solution works great, Matt - we can't seem to implement it upon our own solution! The main issue is that we can't find a real relation between the radius and the x,y coordinates I believe. :( Any help is much appreciated! Thanks in advance!
To create the image above, the following code was used:
x1=236;
y1=400;
x2=-400;
y2=500;
xs=[x1 x2];
ys=[y1 y2];
Lw=101.5;
r=1:100:501;
Lp=Lw-10*log10(4*pi*r.^2);
t=0:pi/36:2*pi;
p2M=ones(length(t),length(r));
LpT=p2M(:,1)*Lp;
for i=1:length(xs)
xL=sin(t)'.*sin(t)'.^2*r+xs(i);
yL=cos(t)'.*sin(t)'.^2*r+ys(i);
figure(1)
surf(xL,yL,LpT)
hold on
end

Answers (1)

You can use polar coordinate system and then you can compute the values of r in terms of x and y.
To convert cartesian to polar coordinate system:
[theta, r, z] = cart2pol(xL,yL, LpT)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 24 Feb 2011

Community Treasure Hunt

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

Start Hunting!