필터 지우기
필터 지우기

How to improve the accuracy of drawing, especially for infinite functions?

조회 수: 2 (최근 30일)
in some plot assignments,we can use 'ezplot' to plot the more accurate figure but for infinite functions the 'ezplot' still can't plot it accurately,so how can we improve the accuracy of drawing, especially for infinite functions?
functions and codes are as this
syms m1;
g=9.8;
h=20;
hgang=20;
omega=2;
nu=omega^2*hgang/g;
g = @(m1) (i*m1)*tanh(i*m1)-nu;
fplot(g,[-10,20])
ylim([-60,40])

채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 13일
Use fplot() instead of ezplot()
And skip using inline(): inline() has been recommended against since MATLAB 5.1
  댓글 수: 11
Walter Roberson
Walter Roberson 2022년 1월 13일
If you have discontinuities and you want to use plot(), then you need to take one of two approaches:
  1. Detect the discontinuities (somehow) and insert a nan at that location so that MATLAB stops drawing there; OR
  2. Use your knowledge of the formulas to draw the lines in pieces, using hold on
If you use the Symbolic Toolbox and you write in terms of piecewise() then fplot() will detect the discontinuities and use vertical lines.
syms a b c d x real
part0 = piecewise(x<=a | x >= d, 0, 0);
part1 = piecewise(x>b & x < c, 1, 0);
part2 = piecewise(x > a & x <= b, (x-a)./(b-a), 0);
part3 = piecewise(x > b & x <= d, (d-x)./(d-c), 0);
f = part0 + part1 + part2 + part3
f = 
m = 10;
v1=unifrnd(0,1,1,m);
l1=unifrnd(0,1,1,m);
u1=unifrnd(1,2,1,m);
A = 0.1*l1';
B = 2*v1';
C = 3*v1';
D = 4*u1';
y = subs(f,{a,b,c,d}, {A,B,C,D});
fplot(y, [-1 3])
hasan s
hasan s 2022년 1월 13일
thank you very very much prof. walter for your reply

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by