Question

plot a 45 degree line using matlab that starts from coordinates (0,0)

plot a 45 degree line using matlab that starts from coordinates (0,0)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer...

CODE:

x1=0 %initial x coordinate
y1=0 %initial y coordinate
l=10 %specify how much does the line have
angle=45 %specify what angle we need
x2=x1+(l*cos(angle)); %specify end point of x2
%cos(45)=5.2532198881 in radians %x2=0+(10*cos(45))=0+10*0.52532198881=5.2532198881
%x2=5
y2=y1+(l*sin(angle)); %specify end point of y2
%y2=0+(10*cos(45))=0+10*0.52532198881=5.2532198881
%y2=5
plot([x1 x2],[y1 y2])

Another Way:

x1=0 %initial x coordinate
y1=0 %initial y coordinate
l=10 %specify how much does the line have
angle=45 %specify what angle we need
x2=x1+(5.2532198881); %specify end point of x2
%cos(45)=5.2532198881 in radians %x2=0+(10*cos(45))=0+10*0.52532198881=5.2532198881
%x2=5
y2=y1+(5.2532198881); %specify end point of y2
%y2=0+(10*cos(45))=0+10*0.52532198881=5.2532198881
%y2=5
plot([x1 x2],[y1 y2])

OUTPUT:

If you have any doubts please COMMENT...

If you understand the answer please give THUMBS UP....

Add a comment
Know the answer?
Add Answer to:
plot a 45 degree line using matlab that starts from coordinates (0,0)
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