Find small squares in big divided square.

6 views (last 30 days)
I want to find all squares in big divided square. But even I have a outline of code. I can't finish this. Could you help me to complete this code?
clear all; clc;
x = [0,2,3,4,5,6,8];
y = [0,2,3,4,5,6,8];
figure(1);
sketchgrid;
filename
VideoWriter
open
for x_i = 1:6
for y_i = 1:6
...
for x_i2 = x_i+1:7
...
if find(y==y3)
...
end
end
end
end
close
function sketchgrid
hold on;
plot([0 0],[0 8],'k-')
plot([2 2],[0 8],'k-')
plot([3 3],[0 8],'r-')
plot([4 4],[0 8],'k-')
plot([5 5],[0 8],'r-')
plot([6 6],[0 8],'k-')
plot([8 8],[0 8],'k-')
plot([0 8],[0 0],'k-')
plot([0 8],[2 2],'k-')
plot([0 8],[3 3],'r-')
plot([0 8],[4 4],'k-')
plot([0 8],[5 5],'r-')
plot([0 8],[6 6],'k-')
plot([0 8],[8 8],'k-')
axis square;
axis([-1 9 -1 9]);
set(gca,'XTick',[0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
set(gca,'YTick',[0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
return
image is example of completed code.

Accepted Answer

KSSV
KSSV on 29 Nov 2016
x = [0,2,3,4,5,6,8];
y = [0,2,3,4,5,6,8];
[X,Y] = meshgrid(x,y) ;
plot(X,Y,'k') ;
hold on
plot(X',Y','k')
Get the successive distances of points in (X,Y) which ever have equal distances they are squares.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!