Can't plot all the four points among the inputs given in an OR Gate.

1 view (last 30 days)
Here's my code for plotting the inputs in an OR Gate but among the four inputs only three gets plotted.Can anyone provide me solution to this??
CODE:
x=[1 0;0 1;0 0;1 1];
y=[1;1;0;1];
plot(x,y,'o')
Here is the output showing only three points rather it should have showen four.
Can anyone please provide me the reason behind this and the solution to overcome this.
  2 Comments
James Tursa
James Tursa on 29 May 2020
It is not clear to me what result you want for the plot. Can you describe what your desired plot would look like?
Saptarshee Sarkar
Saptarshee Sarkar on 30 May 2020
My desired plot should contain a forth point at x-coordinate (1,0) as it skipping that point and showing all the other 3 points.

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 29 May 2020
The way you are using plot() does not make much sense here. Using scatter() with y as the color value will show the difference f true and false values.
x=[1 0;0 1;0 0;1 1];
y=[1;1;0;1];
scatter(x(:,1),x(:,2),[],y,'filled')
colormap(cool)
  8 Comments
Saptarshee Sarkar
Saptarshee Sarkar on 30 May 2020
I have explain the lines of the code by commenting you could refer them.
The optimization ffunction "y=w0+w1*x1+w2*x2"
For the
DJ(1,1)=sum(pred_err)/m;
for j=2:n+1
DJ(j,1)=sum(pred_err.*x(:,j-1))/m;
end
here's the part which would probably explain ,I didn't mebtioned it there because of subscript and superscript.
The red line in the graph is the classiication line which would of the form or near to " x1+x2=1/2 " with assuming the values of w0 = -1 ; w1= 2 ; w3=2 for the case of OR gate.
Saptarshee Sarkar
Saptarshee Sarkar on 30 May 2020
Edited: Saptarshee Sarkar on 30 May 2020
I am also attaching few links below so that you could refer for better understanding:
Code for the logistic regression OR gate (I have copied the above written code from this video)
I would be very thankful if you kindly go through these and help me out for my issue.

Sign in to comment.

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!