How to convert a 1D solution to 2D using spherical axis symmetry

Consider a 1D problem of the nature y =f(x). Now I want to get the solution in 2D using spherical symmetry. After getting the solution not evaluating. The attached file is a trial of my aim. But I got translational instead of rotational.
THE 1D PROFILE
THE 2D PROFILE I WANT
THE 2D PROFILE I GOT

 Respuesta aceptada

Torsten
Torsten el 13 de Abr. de 2015
plot
u(x,y)=f(5+sqrt((x-5)^2+(y-5)^2))
Best wishes
Torsten.

5 comentarios

I have solved a differential equation in 1D ..
dz/dx = sin(x); x = -6:1:6;
Now If I want a solution in 2D using spherical symmetry along vertical axis(x=0) without solving the equation again what should I do.
z(x,y)= cos(x);
What I got was translational symmetry not rotational.
f=@(x)cos(x);
[xx,yy]=ndgrid(-6:0.01:6,-6:0.01:6);
zz=f(sqrt(xx.^2+yy.^2));
mesh(xx,yy,zz);
Best wishes
Torsten.
pfb
pfb el 13 de Abr. de 2015
Editada: pfb el 13 de Abr. de 2015
Not very clear yet. BTW, what is "cos(x,y)"? The cosine has only one argument.
A function with radial symmetry would depend only on the radius. If you have an analytic form for that function, it is enough to create a mesh with the value of the radius at each sample point. For this, look at the documentation of "meshgrid". There are also examples there.
If you solved your problem numerically, you should have a vector of radii, and a vector containing the corresponding values of your solution.
These are not necessarily the values in the square grid you want to use for "mesh" or "surf". You could interpolate your solution to get those points, though.
Otherwise, assuming that r is a column vector containing the radii and f is a column vector of the same size containing the corresponding values, you could try this
% these should come from your calculation
r = linspace(0,20,30)';
f = exp(-0.01*r.^2);
% this should give you the plot you want. You might have to tweak apts to
% get a smooth surface
apts=20;
x=cos(2*pi/apts*(1:apts));
y=sin(2*pi/apts*(1:apts));
xx=ones(size(r))*x;
yy=ones(size(r))*y;
rr=r*ones(size(x));
ff=f*ones(size(x));
mesh(xx.*rr,yy.*rr,ff);
Thanks a lot..This is what I wanted. Sorry the cosine thing was a typo error. I didn't notice it.
Which one did you use? Mine or Thorsten's?

Iniciar sesión para comentar.

Más respuestas (1)

pfb
pfb el 13 de Abr. de 2015
This is not very clear. What do you mean by "the solution of a 1D problem of the nature y=f(x)"?
It seems to me you're plotting curves and surfaces. From a quick look at you code, you're trying to plot a 2D Gaussian. But I'm not sure, because your second plot seems like you already made it.
Anyway, if your problem really is a 2D Gaussian, an easy way is to create a matrix of the radial coordinates.
Take a look at the documentation of meshgrid. That should give you enough inspiration to solve your problem.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Abr. de 2015

Comentada:

pfb
el 14 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by