0

I have a 500*2 matrix. I want to plot this matrix such that it considered two separated matrix, for example, matrix A(1:250,1:2) and matrix B(251:500,1:2). There should be two scatter plots in one graph with two different colors (for example the scatter plot of matrix A will be blue and matrix B will be green). Finally, I need to check if they are linear separable, so one line should be added to the graph.

Some examples of the data:

x: -0.6683, -1.9977, -0.7086, 0.1071, -0.7550

Y: -1.6133, 0.5622, 0.2260, -3.3626, 1.4319

I used this code, but I faced this error: Error using specgraph.scattergroup/set Array must be numeric or logical.

AX = Classes(1:250,1);
AY = Classes(1:250,2);
BX = Classes(251:500,1);
BY = Classes(251:500,2);

scatter(AX, AY, 'b'); hold on;
scatter(BX, BY, 'g')

Could you please tell me what should I do?

user36729
  • 545
  • 5
  • 30
  • Start by taking a look here maybe: http://stackoverflow.com/questions/2481688/matlab-plot-multiple-data-sets-on-a-scatter-plot – Benoit_11 Sep 22 '14 at 14:35
  • ....or in the documentation of [LineSpec](http://www.mathworks.com/help/matlab/ref/linespec.html) – Dev-iL Sep 22 '14 at 14:36
  • I faced this error: Error using specgraph.scattergroup/set Array must be numeric or logical. – user36729 Sep 22 '14 at 14:52
  • I wrote examples of data, they are numeric. Why this error appears? – user36729 Sep 22 '14 at 14:52
  • Please show the code you use so we don't have to guess as to what you did. Thanks! – Benoit_11 Sep 22 '14 at 14:54
  • Please let me know if you need me to add something. – user36729 Sep 22 '14 at 14:59
  • I generated `Classes` by using `rand(500,2)`. Then I run the codes: `AX = Classes(1:250,1)...scatter(BX, BY, 'g')`, but successfully got the figure. Where did you exactly get the error? More details of every step might be helpful, I guess. Or there may be something wrong with the `Classes`. – thundertrick Sep 22 '14 at 15:07
  • @thundertrick: I used the same code but this error appeared: Error using specgraph.scattergroup/set Array must be numeric or logical. – user36729 Sep 22 '14 at 15:11
  • @user36729 Sorry for the uncompleted comment. My advice is giving more details about every step. i.e. 1. Generate Matrix.. 2. ..3. ..4..(get the error message) – thundertrick Sep 22 '14 at 15:17

0 Answers0