필터 지우기
필터 지우기

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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by