フィルターのクリア

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

10 ビュー (過去 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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by