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?
Mostra commenti meno recenti
I will be thankful to your reply..
1 Commento
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.
Risposte (3)
Walter Roberson
il 3 Dic 2012
0 voti
plot(). And fsolve()
1 Commento
vb
il 3 Dic 2012
Modificato: Walter Roberson
il 3 Dic 2012
vb
il 3 Dic 2012
Modificato: Walter Roberson
il 3 Dic 2012
10 Commenti
Muruganandham Subramanian
il 3 Dic 2012
did you try my above code?
vb
il 3 Dic 2012
Muruganandham Subramanian
il 3 Dic 2012
Andrei Bobrov
il 3 Dic 2012
Modificato: Andrei Bobrov
il 3 Dic 2012
x=linspace(0,2,1000).';
y1=cos(x);
y2=x.^2;
plot([y1 y2]);
Walter Roberson
il 3 Dic 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
il 4 Dic 2012
Modificato: Walter Roberson
il 4 Dic 2012
Walter Roberson
il 4 Dic 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
il 4 Dic 2012
Walter Roberson
il 4 Dic 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
il 4 Dic 2012
NEERAJA
il 13 Gen 2024
0 voti
Plot y x sin over 0 2 x with appropriate labels
1 Commento
Walter Roberson
il 13 Gen 2024
It is not clear to me that this would solve the original problem ?
Categorie
Scopri di più su Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!