How to create a graph without knowing the data points?

3 views (last 30 days)
Hi
I am trying to create the following graph (exponential when service level goes to 100%) in Matlab (see attached) but can't seem to make it work as I have no data points (function) given.
Note: 'safety stock requirements' is the label of the y-axis.
How can I do this?
Thanks a lot in advance! I really appreciate it!

Accepted Answer

Star Strider
Star Strider on 26 Mar 2017
I am not certain what the exponential function parameters would be (and you had not previously mentioned that it was exponential), so I presented a hyperbola that appeared to match the appearance of the plot in my Comment to your previous Question.
  2 Comments
Pieter Cecat
Pieter Cecat on 26 Mar 2017
I have replicated your graph. Thank you for that! I am not sure whether or not it is exponential which is why I did not explicitly mention it.
Best regards Pieter
Star Strider
Star Strider on 26 Mar 2017
My pleasure!
It appeared more hyperbolic than exponential to me. I experimented with an exponential function and could not replicate your plot with what I considered to be sufficient accuracy.
This does a much better approximation. Choose the value of ‘n’ that works best for you.
The Code
x = linspace(0, 100, 250);
n = 75;
y = 10^(2*n)./(10^(2*n) - (x+1).^n);
y(y < 1) = NaN;
figure(1)
plot(x, y)
set(gca, 'YLim',[0 5])
It scales and translates automatically so you only need to experiment with various values of ‘n’. The NaN assignments prevent ‘y’-values less than the set minimum from plotting.

Sign in to comment.

More Answers (0)

Categories

Find more on Networks 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!