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])

请先登录,再进行评论。

更多回答(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