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 commentaires

kowshik Thopalli
kowshik Thopalli le 20 Mar 2017
Modifié(e) : kowshik Thopalli le 20 Mar 2017
use hold on and hold off commands.
help hold
Pieter Cecat
Pieter Cecat le 20 Mar 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!!

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 20 Mar 2017
‘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 commentaires

Pieter Cecat
Pieter Cecat le 20 Mar 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 le 26 Mar 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')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by