How to plot coupling functions?

1 view (last 30 days)
Toshith Vats
Toshith Vats on 8 Jun 2021
Commented: Toshith Vats on 11 Jun 2021
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 Comments
Cris LaPierre
Cris LaPierre on 8 Jun 2021
Without seeing your code, it's hard to say why your plot was empty.
Toshith Vats
Toshith Vats on 8 Jun 2021
Kindly check now I have upated

Sign in to comment.

Answers (1)

Cris LaPierre
Cris LaPierre on 8 Jun 2021
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 Comments
Cris LaPierre
Cris LaPierre on 9 Jun 2021
I'm not sure I've seen recursive integration before. Perhaps someone else can provide insight on that.
Toshith Vats
Toshith Vats on 11 Jun 2021
Thabnks fot the help

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!