v = 5 - x - y;
a = 8 - 2*x - y;
plot(v, '-g'); hold on;
plot(a, '-b'); hold on;
w = 8 - x - 2*y;
plot(w, '-r'); hold on;
here's the result:
What's wrong?

回答 (2 件)

Star Strider
Star Strider 2018 年 10 月 19 日
編集済み: Star Strider 2018 年 10 月 19 日

0 投票

Nothing is wrong.
Note that if the ‘x’ and ‘y’ vectors have the same values, ‘a’ and ‘w’ are the same, so ‘w’ over-plots ‘a’.
EDIT (20:30)
What are the values of ‘x’ and ‘y’?

4 件のコメント

Joshua Sinamo
Joshua Sinamo 2018 年 10 月 20 日
I think it supposed to look like this in regards to the line
Edit 2: u, a, v, x, y suppose to be positive
Star Strider
Star Strider 2018 年 10 月 20 日
What are the numeric values of ‘x’ and ‘y’ ?
Joshua Sinamo
Joshua Sinamo 2018 年 10 月 20 日
X >= 0 and y >= 0
Star Strider
Star Strider 2018 年 10 月 20 日
編集済み: Star Strider 2018 年 10 月 20 日
So if any numbers will do, try this:
x = [1 9];
y = [7 2];
v = 5 - x - y;
a = 8 - 2*x - y;
plot(v, '-g'); hold on;
plot(a, '-b'); hold on;
w = 8 - x - 2*y;
plot(w, '-r'); hold on;
That produces 3 distinct lines.
—————
EDIT (20:32)
I still have no idea what you are doing or what you (and probably your instructor) want.
However, if you arbitrarily choose any two values for ‘x’, you can calculate the corresponding values for ‘y’, and that defines the relevant lines in the plot you posted.
x = [0; 8]
v = 5 - x - y % Equation
vy = 5 - x % Find Corresponding ‘y’ Values
a = 8 - 2*x - y
ay = 8 - 2*x
w = 8 - x - 2*y
wy = (8 - x)/2
You can then substitute in the corresponding values for both ‘x’ and ‘y’ to replicate the curves in your plot.
Since I still have no idea what you are doing or what Question you are asking, I will delete my Answer (and all the subsequent Comments to it) in a few days if this is not what you want.

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

madhan ravi
madhan ravi 2018 年 10 月 20 日
編集済み: madhan ravi 2018 年 10 月 20 日

0 投票

Try:
syms x y
v = 5 - x - y;
a = 8 - 2*x - y;
w = 8 - x - 2*y;
h=ezplot(v);
h.Color='g'
hold on;
h1=ezplot(a)
h1.Color='b'
h2=ezplot(w)
h2.Color='r'
grid on
axis equal

5 件のコメント

Joshua Sinamo
Joshua Sinamo 2018 年 10 月 20 日
Do you have any alternatives without using the symbolic math toolbox?
madhan ravi
madhan ravi 2018 年 10 月 20 日
編集済み: madhan ravi 2018 年 10 月 20 日
x = linspace(0,1000,1000); %x greater than zero so is y
y = x;
v = 5 - x - y;
a = 8 - 2*x - y;
w = 8 - x - 2*y;
plot(v,'r')
hold on
plot(a,'g')
hold on
plot(w,'-ob')
madhan ravi
madhan ravi 2018 年 10 月 20 日
a and w are overwritten each other but how does symbolic toolbox evaluate the values ? +1 for your question
Joshua Sinamo
Joshua Sinamo 2018 年 10 月 20 日
The code still not showing the graph that I wanted. I saw that there are 2 functions which overlap with the other one according to matlab graph, but those functions are supposed to look like this on the graph. I graphed this on desmos
Those two functions are : 8 - x - 2y and 8 - 2x - y; or am I wrong on this?
madhan ravi
madhan ravi 2018 年 10 月 20 日
as I said symbolic toolbox evaluates it correctly but why doesn't the numerical solution correlate? it's a mystery to me now

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

カテゴリ

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

タグ

質問済み:

2018 年 10 月 19 日

編集済み:

2018 年 10 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by