Why does it say f plot error line 97
Mostrar comentarios más antiguos
I have the equation from ysol is 3*cos(2*x) - 3*exp(-3*x) - 2*sin(2*x) however whenever i plot it using fplot it gives me an error Index exceeds matrix dimensions.
Error in fplot (line 97) xmin = min(lims(1:2)); xmax = max(lims(1:2));
Heres my codes
ySol(x) = dsolve(ode,conds)
ySol = simplify(ySol);
x = 0.0:1.:30.0;
figure
fplot(ySol,'r',[0 30])
Respuestas (1)
Star Strider
el 14 de Mayo de 2017
Since ‘x’ is the independent variable in your equation, do not define it as a vector if you want to use the fplot function. Leave it undefined, and fplot will implicitly consider ‘ySol’ as a single-variable function.
This works:
ySol = 3*cos(2*x) - 3*exp(-3*x) - 2*sin(2*x);
figure
fplot(ySol,'r',[0 30])
4 comentarios
Maria De Silva
el 14 de Mayo de 2017
Star Strider
el 14 de Mayo de 2017
The code I posted works correctly.
What is your original differential equation?
Please post all your code. I cannot determine where the problem begins without seeing everything you did.
Maria De Silva
el 14 de Mayo de 2017
Editada: Star Strider
el 14 de Mayo de 2017
Star Strider
el 14 de Mayo de 2017
Your code as you posted it works perfectly for me and produces this plot (in R2017a):

Categorías
Más información sobre Calculus en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!