How to plot a polynomial function, having the ordinate coordinates symmetrical about the abscissa (horizontal line)
Show older comments
This the plot I desire to reproduce in matlab


Answers (1)
Well, it's not too hard to get reasonably close...you don't have enough points on yours for the smooth line...the following code
p=[-6 -8 -10 -12 20 30 -20];
fny=@(x) polyval(p,1./(1+x/100));
i=0:0.01:100;
hL=plot(i,fny(i));
hAx=gca;
hAx.Box='off';
hAx.YLim=[-7 3];
hAx.XAxisLocation="origin";
hAx.YAxis.TickLabelFormat='%0.2f';
hAx.XAxis.TickLabelFormat='%0.0f%%';
hAx.XAxis.TickLabel(end)={num2str(hAx.XTick(end),hAx.XAxis.TickLabelFormat)};
hF=gcf;
hF.Color=[1 1 1];
hTy=text(0,3*1.1,'NPV',"HorizontalAlignment",'right',"VerticalAlignment",'baseline');
hTx=text(100,0,'i');
produced:

I'll leave the additional text annotations to you...the only "gotctha's!" I found are the x-axis tick labels aren't drawn for the two endpoints when the axis is at the origin; even replacing the empty string that occurs automagically in the 'XTickLabel' property didn't cause it to be displayed. I didn't delve further to see if could figure out a way to override that behavior.
The biggies are to use enough points to show a smooth curve and to define the functional with the actual range of the independent variables you wish to use.
The rest is either just a simpler way to write the function using the Matlab builtin toolset or just setting HG properties as desired...
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!