How to create a graph without knowing the data points?

2 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Star Strider
Star Strider il 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 Commenti
Pieter Cecat
Pieter Cecat il 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 il 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Networks 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!

Translated by