I am inexperienced in using Matlab and am trying to plot a graph. The function and what it should look like can be found in the pictures attached.
Difference with the graph attached is that the curve should be mirrored. In other words, for q = 0, c(q) should be Alpha1 and for q = 1, c(q) should be Alpha0.
My attempts so far have not been very successful. Any help would thus be appreciated! Thank you in advance!
I'm using Matlab 9-1

2 Kommentare

kowshik Thopalli
kowshik Thopalli am 20 Mär. 2017
Bearbeitet: kowshik Thopalli am 20 Mär. 2017
use hold on and hold off commands.
help hold
Pieter Cecat
Pieter Cecat am 20 Mär. 2017
Unfortunately I did not create the graph attached so any help would be welcome, where the graph is mirrored right away. Thank you very much!!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 20 Mär. 2017

0 Stimmen

‘In other words, for q = 0, c(q) should be Alpha1 and for q = 1, c(q) should be Alpha0.’
That is not the way the formula for c(q) is written. For q=0, c(q) should be a0, and it is, and for q=1, c(q) should be a1, and it is.
The Code
q = linspace(0, 1);
a0 = 60;
a1 = 25;
c = @(q,b) a0 + (a1 - a0).*(q.^b);
b = [1/3 1 3];
[Q,B] = meshgrid(q,b);
figure(1)
plot(q, c(Q,B))

4 Kommentare

Pieter Cecat
Pieter Cecat am 20 Mär. 2017
Thank you very much! I was wondering if it is possible to add labels to my graphs (beta for each line) as well as to name my axes.
Thanks a lot! I appreciate your help!
My pleasure!
The code changes slightly to accommodate the labels for the curves.
The Code
q = linspace(0, 1);
a0 = 60;
a1 = 25;
c = @(q,b) a0 + (a1 - a0).*(q.^b);
b = [1/3 1 3];
[Q,B] = meshgrid(q,b);
cq = c(Q,B);
CL = cq(:,40);
figure(1)
plot(q, cq)
xlabel('\itq\rm')
ylabel('\itc(q)\rm')
text([1 1 1]*0.4, CL, {'\beta = 1/3','\beta = 1','\beta = 3'}, 'HorizontalAlignment','right', 'VerticalAlignment','top')
Pieter Cecat
Pieter Cecat am 26 Mär. 2017
Hi I have another question and was hoping you could help me out again.
I am trying to create the following graph in Matlab (see attached) but can't seem to make it work as I have no data points 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!
This is as close as I can get:
x = linspace(0,100);
y = 1./(100 - x);
figure(1)
plot(x, y)
set(gca, 'XLim',[80 100])
xlabel('Service Level (%)')
ylabel('Safety Stock Requirements')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by