Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
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])

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Mai 2019
Use fplot() instead of ezplot()
And skip using inline(): inline() has been recommended against since MATLAB 5.1
  11 commentaires
Walter Roberson
Walter Roberson le 13 Jan 2022
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 le 13 Jan 2022
thank you very very much prof. walter for your reply

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by