Need help; Fixing error and plotting functions

Hi everyone,
I am working with plotting the following set of expressions. It shows some error that I can't fix. Kindly look into it and help show the plots.
x = linspace(0, 5);
y1=(-(2.844015460*(1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.787032085)*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), 2-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), (2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463))./((1+1603*x*(1/997)).*(1-x).^2.5)+2.787032085.*hypergeom(-1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), 1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), (2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463)).*(-1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))./((1+1603*x*(1/997)).*(1-x).^2.5))./(-(2.844015460*(1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.787032085)*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), 2-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), (2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463))./((1+1603*x*(1/997)).*(1-x).^2.5)+hypergeom(-1-(2.787032085.*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5), 1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x.*(1/997)).*(1-x).^2.5), (2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(-1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).^2);
plot(x,y1,'-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
xlabel('\fontname{Times New Roman} Values of x','FontSize',22)
ylabel('\fontname{Times New Roman} Values of y', 'FontSize', 22)
hold on
y2=(((-1.260902791).*(1+(.1992256641).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom(((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 2+((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), (1.260902791.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5)+.1992256641.*hypergeom(-1+((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 1+((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), (1.260902791.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463)).*(-1+(.1992256641.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5))./((1+1603.*x.*(1/997)).*(1-x).^2.5))./(-1.891354186.*hypergeom(((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 2+(-.1992256641).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5), (1.260902791.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1+(.1992256641.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5)+hypergeom(-1+((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 1+((-.1992256641).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), (1.260902791.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(-1+(.1992256641.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(-1.+(.2988384962.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)));
plot(x,y2,'-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
y3=((.2205657803.*(1-(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom((1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 2+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), ((-.2205657803).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5)-1.498354984.*hypergeom(-1+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 1+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), ((-.2205657803).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463)).*(-1-(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5))./((1+1603.*x.*(1/997)).*(1-x).^2.5))./(.4411315605.*hypergeom((1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 2+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), ((-.2205657803).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(1-4163863.*x.*(1/4166463))./((1+1603.*x.*(1/997)).*(1-x).^2.5)+hypergeom(-1+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), 1+(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5), ((-.2205657803).*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(-1-(1.498354984.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)).*(-1-(2.996709968.*(1-4163863.*x.*(1/4166463)))./((1+1603.*x.*(1/997)).*(1-x).^2.5)));
plot(x,y2,'-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
y4=(-(2.878360445.*(1+(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.820688929).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (2.878360445.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)+2.820688929.*hypergeom(-1-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (2.878360445.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463)).*(-1+(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))./((1+603.*x.*(1/997)).*(1-x).^2.5))./(-(2.878360445.*(1+(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.820688929).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (2.878360445.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)+hypergeom(-1-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1-(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (2.878360445.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(-1+(2.820688929.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).^2);
plot(x,y4,'-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} MWCNT','LineWidth', 2.0)
y5=(((-1.291684341).*(1+(.2040892228.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom(((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (1.291684341.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)+.2040892228.*hypergeom(-1+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (1.291684341.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463)).*(-1+(.2040892228.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))./((1+603.*x.*(1/997)).*(1-x).^2.5))./(-1.937526512.*hypergeom(((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (1.291684341.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1+(.2040892228.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)+hypergeom(-1+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1+((-.2040892228).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), (1.291684341.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(-1+(.2040892228.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(-1.+(.3061338342.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)));
plot(x,y5,'-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=1.0','LineWidth', 2.0, 'HandleVisibility','off')
y6=((.2306233919.*(1-(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))).*hypergeom((1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), ((-.2306233919).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)-1.566678694.*hypergeom(-1+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), ((-.2306233919).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463)).*(-1-(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5))./((1+603.*x.*(1/997)).*(1-x).^2.5))./(.4612467837.*hypergeom((1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 2+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), ((-.2306233919).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(1-4164863.*x.*(1/4166463))./((1+603.*x.*(1/997)).*(1-x).^2.5)+hypergeom(-1+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), 1+(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5), ((-.2306233919).*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(-1-(1.566678694.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)).*(-1-(3.133357388.*(1-4164863.*x.*(1/4166463)))./((1+603.*x.*(1/997)).*(1-x).^2.5)));
plot(x,y6,'-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=1.0','LineWidth', 2.0, 'HandleVisibility','off')
ax = gca; % current axes
ax.FontSize = 22;
set(gca,'XLim',[0 5]);
set(gca,'YLim',[-1 1]);
box off
hold off
Here is the error message:
Error using sym/hypergeom (line 43)
Unable to evaluate to Boolean.
Error in sym.useSymForNumeric (line 165)
res = cast(fn(args{:}),superiorfloat(varargin{:}));
Error in hypergeom (line 41)
h = sym.useSymForNumeric(@hypergeom,n,d,z);
Error in TemNuss (line 543)
y1=(-(2.844015460*(1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.787032085)*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
2-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
(2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463))./((1+1603*x*(1/997)).*(1-x).^2.5)+2.787032085.*hypergeom(-1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
(2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463)).*(-1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))./((1+1603*x*(1/997)).*(1-x).^2.5))./(-(2.844015460*(1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5))).*hypergeom(((-2.787032085)*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
2-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
(2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(1-4163863*x*(1/4166463))./((1+1603*x*(1/997)).*(1-x).^2.5)+hypergeom(-1-(2.787032085.*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5),
1-(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x.*(1/997)).*(1-x).^2.5),
(2.844015460*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).*(-1+(2.787032085*(1-4163863*x*(1/4166463)))./((1+1603*x*(1/997)).*(1-x).^2.5)).^2);

2 Comments

Can you make your code more clear?
One can take only a single expression and try plotting.

Sign in to comment.

 Accepted Answer

I do not encounter that error. However, the code was pretty slow, so I cleaned it up and told it to optimize the calculations.
Caution: every one of your results is complex valued because of the values that you are taking ^2.5 are mostly negative. In the below code, I plot abs() of the values.
The Q() you see are converting the numbers to symbolic rational numbers. This makes the calculations more consistent and gives greater optimization opportunities (floating point calculations are not commutative but rational calculations are.)
You were using the same floating point constants over 100 times in some cases. I gave names to them.
Next time that you are generating code like you did this time, put in variables in place of the constants and generate the code with the variables and then you can insert assignments of values to the variables. This will make the generated code easier to read and less error prone.
X = linspace(0, 5, 25);
syms x
Q = @(v) sym(v);
C603_ = Q(603);
C997_ = 1/Q(997);
C1603_ = Q(1603);
C4163_ = Q(4163863);
C4164_ = Q(4164863);
C4166_ = 1/Q(4166463);
C0199 = Q(.1992256641);
C0204 = Q(.2040892228);
C0220 = Q(.2205657803);
C0230 = Q(.2306233919);
C0298 = Q(.2988384962);
C0306 = Q(.3061338342);
C0441 = Q(.4411315605);
C0461 = Q(.4612467837);
C1260 = Q(1.260902791);
C1291 = Q(1.291684341);
C1487 = Q(1.498354984);
C1566 = Q(1.566678694);
C1891 = Q(1.891354186);
C1937 = Q(1.937526512);
C2500 = Q(2.5);
C2787 = Q(2.787032085);
C2820 = Q(2.820688929);
C2844 = Q(2.844015460);
C2878 = Q(2.878360445);
C2996 = Q(2.996709968);
C3133 = Q(3.133357388);
P43_46 = C4163_ .* C4166_;
P44_46 = C4164_ .* C4166_;
P1_9 = C1603_ .* C997_;
P6_9 = C603_ .* C997_;
f1 = (-(C2844*(1+(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))).*hypergeom(((-C2787)*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2-(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C2844*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)+C2787.*hypergeom(-1-(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1-(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C2844*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x).*(-1+(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))./((1+P1_9.*x).*(1-x).^C2500))./(-(C2844*(1+(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))).*hypergeom(((-C2787)*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2-(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C2844*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)+hypergeom(-1-(C2787.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1-(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C2844*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(-1+(C2787*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).^2);
F1 = matlabFunction(f1, 'File', 'F1.m', 'optimize', true);
y1 = F1(X);
plot(X, abs(y1), '-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
xlabel('\fontname{Times New Roman} Values of x','FontSize',22)
ylabel('\fontname{Times New Roman} Values of y', 'FontSize', 22)
hold on
f2 = (((-C1260).*(1+(C0199).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500))).*hypergeom(((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2+((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C1260.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)+C0199.*hypergeom(-1+((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1+((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C1260.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x).*(-1+(C0199.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))./((1+P1_9.*x).*(1-x).^C2500))./(-C1891.*hypergeom(((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2+(-C0199).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500), (C1260.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1+(C0199.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)+hypergeom(-1+((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1+((-C0199).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), (C1260.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(-1+(C0199.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(-1.+(C0298.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)));
F2 = matlabFunction(f2, 'File', 'F2.m', 'optimize', true);
y2 = F2(X);
plot(X, abs(y2), '-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
f3 = ((C0220.*(1-(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))).*hypergeom((C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), ((-C0220).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)-C1487.*hypergeom(-1+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), ((-C0220).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x).*(-1-(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500))./((1+P1_9.*x).*(1-x).^C2500))./(C0441.*hypergeom((C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 2+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), ((-C0220).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(1-P43_46.*x)./((1+P1_9.*x).*(1-x).^C2500)+hypergeom(-1+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), 1+(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500), ((-C0220).*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(-1-(C1487.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)).*(-1-(C2996.*(1-P43_46.*x))./((1+P1_9.*x).*(1-x).^C2500)));
F3 = matlabFunction(f3, 'File', 'F3.m', 'optimize', true);
y3 = F3(X);
plot(X, abs(y3), '-','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=-0.5','LineWidth', 2.0, 'HandleVisibility','off')
f4 = (-(C2878.*(1+(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))).*hypergeom(((-C2820).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C2878.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)+C2820.*hypergeom(-1-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C2878.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x).*(-1+(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))./((1+P6_9.*x).*(1-x).^C2500))./(-(C2878.*(1+(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))).*hypergeom(((-C2820).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C2878.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)+hypergeom(-1-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1-(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C2878.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(-1+(C2820.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).^2);
F4 = matlabFunction(f4, 'File', 'F4.m', 'optimize', true);
y4 = F4(X);
plot(X, abs(y4), '-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} MWCNT','LineWidth', 2.0)
f5 = (((-C1291).*(1+(C0204.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))).*hypergeom(((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C1291.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)+C0204.*hypergeom(-1+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C1291.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x).*(-1+(C0204.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))./((1+P6_9.*x).*(1-x).^C2500))./(-C1937.*hypergeom(((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C1291.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1+(C0204.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)+hypergeom(-1+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1+((-C0204).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), (C1291.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(-1+(C0204.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(-1.+(C0306.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)));
F5 = matlabFunction(f5, 'File', 'F5.m', 'optimize', true);
y5 = F5(X);
plot(X, abs(y5), '-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=1.0','LineWidth', 2.0, 'HandleVisibility','off')
f6 =((C0230.*(1-(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))).*hypergeom((C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), ((-C0230).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)-C1566.*hypergeom(-1+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), ((-C0230).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x).*(-1-(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500))./((1+P6_9.*x).*(1-x).^C2500))./(C0461.*hypergeom((C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 2+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), ((-C0230).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(1-P44_46.*x)./((1+P6_9.*x).*(1-x).^C2500)+hypergeom(-1+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), 1+(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500), ((-C0230).*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(-1-(C1566.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)).*(-1-(C3133.*(1-P44_46.*x))./((1+P6_9.*x).*(1-x).^C2500)));
F6 = matlabFunction(f6, 'File', 'F6.m', 'optimize', true);
y6 = F6(X);
plot(X, abs(y6), '-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{18} s=1.0','LineWidth', 2.0, 'HandleVisibility','off')
ax = gca; % current axes
ax.FontSize = 22;
set(gca,'XLim',[0 5]);
set(gca,'YLim',[-1 12]);
box off
hold off

6 Comments

Unfortunately I forgot that there is currently a bug that can cause mis-optimization when you use matlabFunction with 'optimize', true . You should probably change the 'optimize' to false to be sure.
(Or you could test both ways, and see if they give the same result; the bug might not affect all expressions.)
It worked for me. I love the part when the code is running very fast. Thank you very much. I just wonder how the first time, you didn't encouter an issue? It would mean we're using different versions or what should I do not to encounter such issues in future?
I was working in R2020a; which release were you working in?
I am wokring with the same system. It is because I didn't install the full version, that is, I didn't opt some programs for my installation?
Gosh your original code is slow!
How long did you have to execute before you got the error about unable to convert to boolean?
The previous ones were good, but a new value for a paramter made it too slow. The last time I ran it took me half an hour or even more.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Asked:

on 28 Jun 2020

Commented:

on 30 Jun 2020

Community Treasure Hunt

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

Start Hunting!