How to plot 3 line graphs on same graph

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 Comments

use hold on and hold off commands.
help hold
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!!

Sign in to comment.

 Accepted Answer

‘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 Comments

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')
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')

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!