"Roger Stafford" wrote in message <jjbupc$m25$1@newscl01ah.mathworks.com>...
> "Roland " <burgmann@gmx.de> wrote in message <jjbbul$r7c$1@newscl01ah.mathworks.com>...
> > I want to plot a curve with a constant curvature. this code works very well:
> >
> > function curv()
> > data.beta_2=89*pi/180;
> > data.beta_1=20*pi/180;
> > data.z_2 = 0;
> > data.z_1 = 1;
> > opts = odeset('events',@(u,z) cross_z_z_min(u,z,data));
> > [u,z]=ode45(@(u,z) fun_dz_du(u,z,data),[0 inf],data.z_1,opts);
> > plot(u,z)
> > axis equal
> >
> > function dz_du = fun_dz_du(u,z,data)
> > beta_2=data.beta_2;
> > beta_1=data.beta_1;
> > z_2 = data.z_2;
> > z_1 = data.z_1;
> > beta = beta_1  (beta_1beta_2)*(zz_1)/(z_2z_1);
> > dz_du = tan(beta);
> >
> > function [gstop,isterminal,direction]=cross_z_z_min(u,z,data)
> > gstop = zdata.z_2;
> > isterminal = 1;
> > direction = [];
> >
> > whereas when I change beta_2 to 91 degree the ode solver hangs up. I guess its related to the singularity of the tan function at 90 degree, but I dont know how to overcome that problem. Any ideas?
>          
> This differential equation can be solved without using 'ode15'. The solution (if I understand your code correctly) is:
>
> z = 1/(b2b1)*(b2asin(sin(b1)*exp((b2b1)*u)))
>
> where b1 = data.beta_1 and b2 = data.beta_2, and ode45 is set to terminate when z descends to 0. If you have b2 > pi/2, then before the termination can occur the quantity inside the arcsine will eventually exceed 1 at which point it all blows up, but if b2 < pi/2 then ode45 terminates first before that can happen. Without your termination option, it would have hung up with either value of b2. The only way I can think of to "overcome" such a hang up is to change your criterion as to when ode45 is to stop. Stop it before b2(b2b1)*z gets past pi/2.
>
> What I don't understand is why you claim that this curve has a constant curvature. The only curves with constant curvature are circles and this curve is surely not a circle.
>
> Roger Stafford

thank you Roger for your reply.
you are right, this does not create a curve with constant curvature. But what i want is a curve with a prescribed beta distribution along z.
In this example, the distribution is linear, but it should be able to have any shape. thats why i prefere to use the ode solver.
I am not shure if i understood correctly your suggestion. should i split up the function, one part for
beta < pi /2
and one for
beta > pi/2?
