필터 지우기
필터 지우기

Concentric Squares with random points

조회 수: 2 (최근 30일)
Lewis HC
Lewis HC 2020년 5월 23일
댓글: Rena Berman 2020년 6월 1일
Hi to everybody
Someone could I help me how to create a script for two concentric squares so that I have a set of points in the difference of areas?
I have this initial code:
With the last script I reach to create two areas but I need only the points in the difference of areas
Thank you to everybody!
Thank you guys!!!
  댓글 수: 2
KSSV
KSSV 2020년 5월 23일
편집: KSSV 2020년 5월 23일
You have changed the original question.....even you have unaccepted the accepted answer, even you have deleted your comment where you said thanks for the solution....why? It is not ethical of you.
Rena Berman
Rena Berman 2020년 6월 1일
(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2020년 5월 23일
clc; clear all ;
% Inner Square
S1 = [-5 -5 ; 5 -5 ; 5 5 ; -5 5] ;
% Outer Square
S2 = [-10 -10 ; 10 -10 ; 10 10 ; -10 10] ;
% Generqate random points
a = -10 ; b = 10 ;
N = 100000 ;
x = (b-a)*rand(N,1)+a ;
y = (b-a)*rand(N,1)+a ;
% poins which lie inside S1
idx = inpolygon(x,y,S1(:,1),S1(:,2)) ;
% plot
x = x(~idx) ; y = y(~idx) ;
plot(x,y,'.b')
  댓글 수: 2
Lewis HC
Lewis HC 2020년 5월 23일
Thank you friend!!!
Another question...is it posible get a same squares using for, while, else, etc??...thank you friend!!!
KSSV
KSSV 2020년 5월 23일
Very much possible...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by