What causes difference between ezplot and fplot for the same function plotted below?
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Asiegbu Kanu-Asiegbu
el 1 de Abr. de 2018
Respondida: ahmad amer
el 19 de Dic. de 2018
Trying to understand difference between ezplot and fplot? When script below is graphed for ezplot around 0.2 sec there appear to be 2 changes in slope of line. Howeve, for fplot around 0.2 sec there is only 1 change in slope of the line (which is the desired result)
%% Code
Fo = 3000; %N
to = 0.2; %s
syms t
F = (Fo/to)*(t*heaviside(t)-(t)*heaviside(t-to)+ to*heaviside(t-to)-to* heaviside(t-5*to) );
%%%%%%%%%%%%%
figure (1)
ezplot(F, [0, 10*to])
title('From ezPlot')
xlabel('time [s]')
ylabel('Force [N]')
%%%%%%%%%%
figure(2)
fplot(F, [0, 10*to])
title('From fplot')
xlabel('time [s]')
ylabel('Force [N]')
0 comentarios
Respuesta aceptada
lokender Rawat
el 4 de Abr. de 2018
ezplot(f) plots the expression f(x) over the default domain -2π < x < 2π, where f(x) is an explicit function of only x.
Where as, fplot(f) plots the curve defined by the function y = f(x) over the default interval [-5 5] for x.
We can plot the curve over some specified interval as well. The curve that is produced is same for both the functions. But ezplot is not recommended as it behaves differently under different environments and fplot is used instead.
To get the correct alignment with ezplot, you can use the below command right after the ezplot function command as below to adjust the curve:
ezplot(F, [0, 10*to]);
ylim([0,3000])
ylims sets the y-axis limits for the current axes or chart. Both the figures now will have same curve with corresponding values aligned.
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Get Started with Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!