How to find an equilibrium point between two lines?

5 ビュー (過去 30 日間)
Joao Pereira
Joao Pereira 2019 年 12 月 26 日
コメント済み: Rena Berman 2020 年 5 月 14 日
Hi guys could you help me find the equilibrium point between my demand and supply curves cheers.
This is the code I wrote, I tried using the command "solve", but I did not succeed
x = 1:20:14;
xticks(1:1:30)
y1 = -3*x +90;
plot (x,y1,'b')
hold on
x = 1:0.5:30;
y2 = 10+x;
plot (x,y2,'c')
hold on
x = 1:0.5:30;
y3 = -3*x +60;
plot (x,y3,'b')
plot (x,y1,y2,y3)
ylim([0 100])
hold on
legend ('0G demand curve','OG supply curve','tax(30)')
title ('Market Equilibrium')
xlabel('Quantitites')
ylabel('Price')
hold off
P = InterX([x1;y1],[x;y2]);
plot(x,y1,x,y2,P(1,:),P(2,:));
  1 件のコメント
Rena Berman
Rena Berman 2020 年 5 月 14 日
(Answers Dev) Restored edit

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

回答 (1 件)

Mark Sherstan
Mark Sherstan 2019 年 12 月 26 日
You were close! The x domain must be the same length and some of your variables were mislabeled. I quickly cleaned up your code and this should work for you:
x = 1:0.5:30;
y1 = -3*x +90;
y2 = 10+x;
y3 = -3*x +60;
plot(x,y1,'b', x,y2,'c', x,y3,'b')
ylim([0 100])
title ('Market Equilibrium')
xlabel('Quantitites')
ylabel('Price')
P12 = InterX([x;y1],[x;y2])'
P23 = InterX([x;y2],[x;y3])'
hold on
plot(P12(1,1),P12(1,2),'ro')
plot(P23(1,1),P23(1,2),'ko')
legend ('0G demand curve','OG supply curve','tax(30)','Intersection Y1-Y2', 'Intersection Y2-Y3')
hold off
  5 件のコメント
Joao Pereira
Joao Pereira 2019 年 12 月 26 日
Thank you Mark I was working with that function I’ll just keep trying
Mark Sherstan
Mark Sherstan 2019 年 12 月 26 日
As long as the function and my code is in the same folder it will work, I just tested it. So if you need more help just ask!

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

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by