## 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?

on 2 Dec 2012

Matt J

### Matt J (view profile)

on 2 Dec 2012

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.

## Products

No products are associated with this question.

### Walter Roberson (view profile)

on 3 Dec 2012

plot(). And fsolve()

vb

### vb (view profile)

on 3 Dec 2012
```x=linspace(0,2)
y1=cos(x)
y2=x.^2
plot(x,y1)
plot(x,y2)
grid on
```

i tried these but getting only one line so how will i get intersection point

### vb (view profile)

on 3 Dec 2012
Edited by Walter Roberson

### Walter Roberson (view profile)

on 3 Dec 2012

```x=linspace(0,2,1000);
y1=cos(x);
y2=x.^2;
plot(x,y1);
plot(x,y2);
grid on
```

I tried this but i need point of intersection of two curves so when i do this in matlab i get only one curve

vb

### vb (view profile)

on 4 Dec 2012

does the output of fsolve means the graph itself?I tried doing it but didnt get it.

Walter Roberson

### Walter Roberson (view profile)

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

### vb (view profile)

on 4 Dec 2012

thanks a lot

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi