How to plot coupling functions?

3 次查看(过去 30 天)
Toshith Vats
Toshith Vats 2021-6-8
Want to plot these coupling functions r(t) and p(t) (in image) on a graph. I tried using this code and ended up with a blank graph(without errors) . Kindly help. Please note t varies as 2 to 3 with stepping of 0.01 .
z1 = -1.0629;
z2 = 0.5948;
%Code for r(t)
r_int1 = @(s) (2/3 - s).^(-1/2) .* (6 + abs(r(s))+abs(p(s))) ./ (5.*exp(s+4).*(1+abs(r(s))+abs(p(s))));
r_int2 = @(s) (t-s).^(-1/2) .* (6+abs(r(s))+abs(p(s))) ./ (5*exp(s+4).*(1+abs(r(s))+abs(p(s))));
r = @(t) ( z1.*t.^(-1/3)/gamma(1/2) .* integral(r_int1, 0, 2/3) ) + ( (1/gamma(1/2)) .* integral(r_int2, 0, t) );
%Code for p(t)
p_int1 = @(s) (3/2 - s).^(-4/5) .* (1/exp(2*s)) .* (sin(r(s))+sin(p(s)));
p_int2 = @(s) (t - s).^(-4/5) .* (1/exp(2*s)) .* (sin(r(s))+sin(p(s)));
p = @(t) ( z2.*t.^(-3/2)/gamma(1/5) .* integral(p_int1, 0, 3/2) ) + ( (1/gamma(1/5)) .* integral(p_int2, 0, t) );
fp = fplot(r,p,[2 3]);
fp.Marker = '*';
Funtions to be plotted
  2 个评论
Cris LaPierre
Cris LaPierre 2021-6-8
Without seeing your code, it's hard to say why your plot was empty.
Toshith Vats
Toshith Vats 2021-6-8
Kindly check now I have upated

请先登录,再进行评论。

回答(1 个)

Cris LaPierre
Cris LaPierre 2021-6-8
If I don't use fplot, I do get a more descriptive error message. Based on the code you have shared, you are using your function handle r in you computation of r_int1 and r_int2 before it has been defined.
z1 = -1.0629;
z2 = 0.5948;
%Code for r(t)
r_int1 = @(s) (2/3 - s).^(-1/2) .* (6 + abs(r(s))+abs(p(s))) ./ (5.*exp(s+4).*(1+abs(r(s))+abs(p(s))));
r_int2 = @(s) (t-s).^(-1/2) .* (6+abs(r(s))+abs(p(s))) ./ (5*exp(s+4).*(1+abs(r(s))+abs(p(s))));
r = @(t) ( z1.*t.^(-1/3)/gamma(1/2) .* integral(r_int1, 0, 2/3) ) + ( (1/gamma(1/2)) .* integral(r_int2, 0, t) );
%Code for p(t)
p_int1 = @(s) (3/2 - s).^(-4/5) .* (1/exp(2*s)) .* (sin(r(s))+sin(p(s)));
p_int2 = @(s) (t - s).^(-4/5) .* (1/exp(2*s)) .* (sin(r(s))+sin(p(s)));
p = @(t) ( z2.*t.^(-3/2)/gamma(1/5) .* integral(p_int1, 0, 3/2) ) + ( (1/gamma(1/5)) .* integral(p_int2, 0, t) );
% fp = fplot(r,p,[2 3]);
% fp.Marker = '*';
plot(r(2:.01:3),p(2:0.01:3))
Unrecognized function or variable 'r'.

Error in solution (line 5)
r_int1 = @(s) (2/3 - s).^(-1/2) .* (6 + abs(r(s))+abs(p(s))) ./ (5.*exp(s+4).*(1+abs(r(s))+abs(p(s))));

Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);

Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);

Error in solution (line 7)
r = @(t) ( z1.*t.^(-1/3)/gamma(1/2) .* integral(r_int1, 0, 2/3) ) + ( (1/gamma(1/2)) .* integral(r_int2, 0, t) );
  6 个评论
Cris LaPierre
Cris LaPierre 2021-6-9
I'm not sure I've seen recursive integration before. Perhaps someone else can provide insight on that.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Gamma Functions 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by