Question

.Using Matlab: Find the average area of 1000 triangles whose vertices are given by v(k) =...

.Using Matlab:

Find the average area of 1000 triangles whose vertices are given by v(k) = 10(rand() + j rand()) for k=1,2, and 3, in the complex plane. Some of the vertices of the triangles may be co-linear giving a zero area. Use as the first line the command rng(829) to seed the random number generator. Put the average area in the title of a plot in which there is only the last one of the triangles drawn. You may find it useful to set the axes by using axis([0,10,0,10]).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

rng(829);
for m=1:1000
for n=1:3
v(n)=10*(rand()+i*rand());
end
a=abs(v(1)-v(2));
b=abs(v(2)-v(3));
c=abs(v(2)-v(3));
s = (a+b+c)/2;
area(m) = sqrt(s*(s-a)*(s-b)*(s-c));
end
hold on
plot([real(v(1)) real(v(2))], [imag(v(1)) imag(v(2))]);
plot([real(v(2)) real(v(2)+v(3))], [imag(v(2)) imag(v(2)+v(3))]);
plot([real(v(2)+v(3)) real(v(1))], [imag(v(2)+v(3)) imag(v(1))]);
average=mean(area);
title(sprintf('mean area of triangle is', average))

Add a comment
Know the answer?
Add Answer to:
.Using Matlab: Find the average area of 1000 triangles whose vertices are given by v(k) =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT