how to plot the graph for the functions 0<x<2 with y=sin x and y=x^3 and how to get point of intersection?
Show older comments
I will be thankful to your reply..
1 Comment
Replies are unlikely if you show no evidence of having attempted the homework or of having read the MATLAB documentation. If you've done minimal reading of the Getting Started material, you should be aware of the PLOT command and seen examples of its use.
Answers (3)
Walter Roberson
on 3 Dec 2012
0 votes
plot(). And fsolve()
1 Comment
vb
on 3 Dec 2012
Edited: Walter Roberson
on 3 Dec 2012
vb
on 3 Dec 2012
Edited: Walter Roberson
on 3 Dec 2012
10 Comments
Muruganandham Subramanian
on 3 Dec 2012
did you try my above code?
vb
on 3 Dec 2012
Muruganandham Subramanian
on 3 Dec 2012
Andrei Bobrov
on 3 Dec 2012
Edited: Andrei Bobrov
on 3 Dec 2012
x=linspace(0,2,1000).';
y1=cos(x);
y2=x.^2;
plot([y1 y2]);
Walter Roberson
on 3 Dec 2012
MATLAB is not going to tell you what the point of intersection is. You can zoom in near the point of intersection and use the datacursor to find nearby points. Or, without going to that trouble to find a guess, you can use fsolve() to determine where the point of intersection is.
vb
on 4 Dec 2012
Edited: Walter Roberson
on 4 Dec 2012
Walter Roberson
on 4 Dec 2012
If you want to mark or label the point of intersection on the graph, you will have to record the output of fsolve(), calculate the y corresponding to that x, and then create the form of mark that you want such as by using text() or annotate()
vb
on 4 Dec 2012
Walter Roberson
on 4 Dec 2012
x_of_intersection = fsolve(@(x)cos(x)-x.^2,1);
y_of_intersection = cos(x_of_intersection);
text(x_of_intersection, y_of_intersection, 'LOOK HERE')
vb
on 4 Dec 2012
NEERAJA
on 13 Jan 2024
0 votes
Plot y x sin over 0 2 x with appropriate labels
1 Comment
Walter Roberson
on 13 Jan 2024
It is not clear to me that this would solve the original problem ?
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!