How to create a graph without knowing the data points?
조회 수: 2 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
Star Strider
2017년 3월 26일
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
Star Strider
2017년 3월 26일
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!