What causes difference between ezplot and fplot for the same function plotted below?

22 次查看(过去 30 天)
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]')

采纳的回答

lokender Rawat
lokender Rawat 2018-4-4
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.

更多回答(1 个)

ahmad amer
ahmad amer 2018-12-19
ezplot(F, [0, 10*to]);
ylim([0,3000])

类别

Help CenterFile Exchange 中查找有关 Get Started with Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by