Having problem with fixing the issue
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi guys.
Here are some weird functions which I'm trying to plot. I am a novice and did a few more graphs smoothly, however, this one is a bit more tricky. Seems like I'm having some problem with sytax or so. Looking for possible help.
Thanks
Waqar
x = linspace(0,5);
y1=(-15.17006719-10.19830710*I)*((-.3397894164*2^(2/3)-2.584061447*2^(1/3)+15.96541878)*hypergeom([4.811602425], [6.811602422], -6.723676050*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x))+(-11.74363984+.3386696355*2^(2/3)+.9999999998*2^(1/3))*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x)*hypergeom([5.811602424], [7.811602422], -6.723676050*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x)))*(-exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x))^4.811602421;
plot(x,y1,'-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.1, s=-0.1','LineWidth', 2.0)
xlabel('\fontname{Times New Roman} Values of x', 'FontSize', 22)
ylabel('\fontname{Times New Roman} Velocity Profile','FontSize',22')
hold on
y2=(-41.76167543-277.1087639*I)*(-exp(-.6942370405*x))^4.547612589*((0.6153550094e-1*2^(2/3)-2.648960805*2^(1/3)+5.574199339)*hypergeom([4.547612586], [6.547612585], -8.572516010*exp(-.6942370405*x))+(-4.013958993+.1566293604*2^(2/3)+1.000000000*2^(1/3))*exp(-.6942370405*x)*hypergeom([5.547612584], [7.547612587], -8.572516010*exp(-.6942370405*x)));
plot(x,y2, ':','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.1, s=-0.3','LineWidth', 2.0)
y3=(8.054902998+2.463354463*I)*(-exp(-.8175736472*x))^3.90552941*((-2.482855195*2^(1/3)+14.73597244-.2149702398*2^(2/3))*hypergeom([3.905529413], [5.905529410], -5.761721393*exp(-.8175736472*x))+(-10.71834160+.4453954039*2^(2/3)+1.000000000*2^(1/3))*exp(-.8175736472*x)*hypergeom([4.905529411], [6.905529412], -5.761721393*exp(-.8175736472*x)));
plot(x,y3,'--','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.2, s=-0.1','LineWidth', 2.0)
y4=(-12.45342459+98.65993194*I)*((5.141075166+.1059158437*2^(2/3)-2.574899769*2^(1/3))*hypergeom([3.460032462], [5.460032468], -7.288618279*exp(-.7424204657*x))+(-3.715037183+.1994232887*2^(2/3)+1.000000000*2^(1/3))*exp(-.7424204657*x)*hypergeom([4.460032463], [6.460032464], -7.288618279*exp(-.7424204657*x)))*(-exp(-.7424204657*x))^3.460032466;
plot(x,y4,'Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.2, s=-0.3','LineWidth', 2.0)
ax = gca;
ax.FontSize = 19;
set(gca,'XLim',[0 5]);
set(gca,'YLim',[0 1]);
set(gca,'XTick',[0 1 2 3 4 5])
box off
hold off
lgd = legend;
lgd.FontSize = 20;
lgd.Title.String = 'Values of \lambda';
legend;
legend('boxoff')
5 Commenti
Walter Roberson
il 10 Mag 2020
Maple would generate a complex number in that situation as well.
eta := 2;
eta := 2
(-exp(-0.6942370405*eta))^4.547612589;
-0.0002697804212 + 0.001790122601 I
Risposte (2)
Walter Roberson
il 10 Mag 2020
lambda = zeta.^(2/3)
However if you need negative values to have positive results, then
lambda = zeta.^2.^(1/3)
4 Commenti
Walter Roberson
il 11 Mag 2020
In the below, the character vectors for y1_, y2_, y3_, y4_ are exactly the formulas you had in your code. The below code automatically vectorizes the formulas so there will not be any mistakes.
I = 1i;
y1_ = '(-15.17006719-10.19830710*I)*((-.3397894164*2^(2/3)-2.584061447*2^(1/3)+15.96541878)*hypergeom([4.811602425], [6.811602422], -6.723676050*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x))+(-11.74363984+.3386696355*2^(2/3)+.9999999998*2^(1/3))*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x)*hypergeom([5.811602424], [7.811602422], -6.723676050*exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x)))*(-exp(-(-.3666666667+.6297451706*2^(2/3)+.1067451175*2^(1/3))*x))^4.811602421';
y2_ = '(-41.76167543-277.1087639*I)*(-exp(-.6942370405*x))^4.547612589*((0.6153550094e-1*2^(2/3)-2.648960805*2^(1/3)+5.574199339)*hypergeom([4.547612586], [6.547612585], -8.572516010*exp(-.6942370405*x))+(-4.013958993+.1566293604*2^(2/3)+1.000000000*2^(1/3))*exp(-.6942370405*x)*hypergeom([5.547612584], [7.547612587], -8.572516010*exp(-.6942370405*x)))';
y3_ = '(8.054902998+2.463354463*I)*(-exp(-.8175736472*x))^3.90552941*((-2.482855195*2^(1/3)+14.73597244-.2149702398*2^(2/3))*hypergeom([3.905529413], [5.905529410], -5.761721393*exp(-.8175736472*x))+(-10.71834160+.4453954039*2^(2/3)+1.000000000*2^(1/3))*exp(-.8175736472*x)*hypergeom([4.905529411], [6.905529412], -5.761721393*exp(-.8175736472*x)))';
y4_ = '(-12.45342459+98.65993194*I)*((5.141075166+.1059158437*2^(2/3)-2.574899769*2^(1/3))*hypergeom([3.460032462], [5.460032468], -7.288618279*exp(-.7424204657*x))+(-3.715037183+.1994232887*2^(2/3)+1.000000000*2^(1/3))*exp(-.7424204657*x)*hypergeom([4.460032463], [6.460032464], -7.288618279*exp(-.7424204657*x)))*(-exp(-.7424204657*x))^3.460032466';
y1 = str2fun(['@(x,I)', vectorize(y1_)]);
y2 = str2fun(['@(x,I)', vectorize(y2_)]);
y3 = str2fun(['@(x,I)', vectorize(y3_)]);
y4 = str2fun(['@(x,I)', vectorize(y4_)]);
x = linspace(0,5);
plot(x,y1(x,I),'-.','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.1, s=-0.1','LineWidth', 2.0)
xlabel('\fontname{Times New Roman} Values of x', 'FontSize', 22)
ylabel('\fontname{Times New Roman} Velocity Profile','FontSize',22')
hold on
plot(x,y2(x,I), ':','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.1, s=-0.3','LineWidth', 2.0)
plot(x,y3(x,I),'--','Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.2, s=-0.1','LineWidth', 2.0)
plot(x,y4(x,I),'Color','[0 0 0]','DisplayName','\fontname {Helvetica} \fontsize{20} \kappa;=0.2, s=-0.3','LineWidth', 2.0)
ax = gca;
ax.FontSize = 19;
set(gca,'XLim',[0 5]);
set(gca,'YLim',[0 1]);
set(gca,'XTick',[0 1 2 3 4 5])
box off
hold off
lgd = legend;
lgd.FontSize = 20;
lgd.Title.String = 'Values of \lambda';
legend;
legend('boxoff')
Ke Le
il 12 Mag 2020
4 Commenti
Walter Roberson
il 21 Mag 2020
[number] asks MATLAB to build a vector that contains only the number. But in MATLAB every scalar is the exact same thing as a vector of length 1, so as far as MATLAB is concerned, [123] has an identical run-time representation as 123 without [] . The only difference is small run-time penalty.
The y1_ etc version automatically vectorizes so that you do not need to make the changes yourself (potentially missing some of them)
Ignoring the imaginary part is an important change though.
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!