how to plot a straight line of the form y=w1*x1+w2*x2 in matlab

14 ビュー (過去 30 日間)
shruti
shruti 2015 年 1 月 7 日
コメント済み: Amit 2015 年 1 月 7 日
y=w1*x1+w2*x2
x1=[2 10 6 6 1 1 -1 -1]
x2[2 6 6 10 1 -1 -1 1]
w1=0.0839
w2=0.0839
how to plot the line separating these points
  2 件のコメント
David Young
David Young 2015 年 1 月 7 日
What is the independent variable?
shruti
shruti 2015 年 1 月 7 日
no independent variables

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

回答 (3 件)

John D'Errico
John D'Errico 2015 年 1 月 7 日
編集済み: John D'Errico 2015 年 1 月 7 日
You appear to have TWO independent variables, x1 and x2, and a dependent variable, y. As such, this would be a plane in 3 dimensions, thus (x1,x2,y), not a line.
Possibly you want to plot a line in the plane (x1,x2), given the picture, and the fact that you have supplied the coefficients w1 and w2. That line goes through the origin as you have written it though, with a slope of -1.
As far as "separating" some points, it is not obvious what you are trying to separate. The words "discriminating hyperplane" do suggest something, but you have supplied only a fractional part of what that would involve.
I think you need to...
- Talk to your teacher and try to understand what you seem to be confused about.
- Reread your lecture notes. If you don't have any, why not? Take better notes.
- Read your textbook. AGAIN.
- Finally, it is often the case that two students can help each other. Work groups are a great way to resolve problems like this, where each of you helps the other to understand the problems. Do your own work of course, but some discussion time about HOW to do it can be invaluable.
When someone cannot explain their problem clearly, it is almost always a sign that they don't understand what they are asking about. So go back to your notes.
  2 件のコメント
Amit
Amit 2015 年 1 月 7 日
Nice to-do-list!
John D'Errico
John D'Errico 2015 年 1 月 7 日
:)
Too often when someone posts a very fuzzy, very confused question like this, it just means they have no idea what it is they are doing. So for me the rational solution is for them to sit down and figure out enough about their problem that they do understand it. Of course then the answer often falls out as literally trivial.

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


Titus Edelhofer
Titus Edelhofer 2015 年 1 月 7 日
Hi,
what about
plot(y)
Titus
  3 件のコメント
Image Analyst
Image Analyst 2015 年 1 月 7 日
This works for me:
x1 = [2 10 6 6 1 1 -1 -1]
x2 = [2 6 6 10 1 -1 -1 1]
w1 = 0.0839
w2 = 0.0839
y = w1 * x1 + w2 * x2
plot(y, 'bo-');
ylabel('y', 'FontSize', 25);
xlabel('The Index of y', 'FontSize', 25);
Star Strider
Star Strider 2015 年 1 月 7 日
I think OP wants to do something like gscatter as depicted in the documentation for classify.

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


Amit
Amit 2015 年 1 月 7 日
Y = w1*x1 + w2*x2;
I am not sure what is you independent variable (For example, you plot y as a function of x but here you have x1 and x2). I am assuming that you want to plot a 3D plot showing the correlation between y versus x1 and x2.
plot3(x1,x2,Y);
or
scatter3(x1,x2,Y);
  2 件のコメント
David Young
David Young 2015 年 1 月 7 日
If you look at the comments, you'll see that I already asked about the independent variable, and shruti said that there isn't one, which doesn't really make sense.
Amit
Amit 2015 年 1 月 7 日
I know :P. Which is why I took the liberty of interpreting the best I could !

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by