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 件のコメント

kowshik Thopalli
kowshik Thopalli 2017 年 3 月 20 日
編集済み: kowshik Thopalli 2017 年 3 月 20 日
use hold on and hold off commands.
help hold
Pieter Cecat
Pieter Cecat 2017 年 3 月 20 日
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!!

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2017 年 3 月 20 日

0 投票

‘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 件のコメント

Pieter Cecat
Pieter Cecat 2017 年 3 月 20 日
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!
Star Strider
Star Strider 2017 年 3 月 21 日
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 2017 年 3 月 26 日
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!
Star Strider
Star Strider 2017 年 3 月 26 日
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')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by