Simulation for a triangle
이전 댓글 표시
i'm trying to creat a simple script to find the area of a triangle using monte carlo simulation. however, i'm basically stuck. could someone please help me.
any help is appreciated,
thannks
댓글 수: 1
Aswin Farzana Mohamed Ansar
2017년 10월 1일
Thufz can you share the script that you tried with!
채택된 답변
추가 답변 (1개)
Image Analyst
2014년 2월 9일
0 개 추천
You have not specified the 3 vertex coordinates of the triangle. Once you do that you can use inpolygon() to determine if a test point is inside the triangle.
댓글 수: 4
Thufz
2014년 2월 9일
Image Analyst
2014년 2월 9일
Tell me what the vertices are. Tell me what x1, y1, and x2,y2, and x3,y3 are. Then make xv and yv like this
xv = [x1, x2, x3];
yv = [y1, y2, y3];
Then see if x,y is in or out
itsInside = inpolygon(x,y,xv,yv);
If you read the help for inpolygon, you should know how to do it.
Image Analyst
2014년 2월 9일
편집: Image Analyst
2014년 2월 9일
x = [0, 0, 1]
y = [0, 1, 0]
area = polyarea(x, y)
However I don't know how a Monte Carlo could be worked into this. The only way I can see it is if you run it a million times and get random coordinates, but I don't know if that is what you are after.
By the way, don't use max as a variable name or else you will destroy a very important build in function. Same for min.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!