ploting exponential integral function
3 views (last 30 days)
Show older comments
Hi, I'm trying to plot integral of x*exp(-1/x). These are my code,
syms x y1 y2;
y1=x*exp(-1/x);
y2=int(y1)
ezplot(y2)
I've got this error message,
??? Error using ==> inlineeval at 15 Error in inline expression ==> - Ei(-1./x)./2 - (x.^2./(2.*exp(1./x)) - x.^3./(2.*exp(1./x)))./x Undefined function or method 'Ei' for input arguments of type 'double'.
How could I plot it ? Many thanks BJ
0 Comments
Answers (1)
Laura Proctor
on 17 Mar 2011
You can plot it by defining your range of x values and then plugging this into y, something like this:
x = -0.5:0.01:0.5;
y = x.*exp(-1./x);
plot(x,y,'.')
axis([ -0.5 0.5 -10 0.5])
A few comments on this code:
The second line uses element-wise multiplication and division rather than matrix multiplication and division denoted by the dot in front of the operator. http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_oop/br02znk-1.html#br02znk-6
The third line is plotting x versus y with the dot marker (third input). You can learn more about customizing your plots here: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/linespec.html
4 Comments
Laura Proctor
on 17 Mar 2011
Ei is an MFUN function and these do not play well with EZPLOT because EZPLOT looks to be directly plugging in numeric values to create the plot. For MFUN functions, numeric values need to be plugged in with MFUN and cannot be plugged in directly.
Walter Roberson
on 17 Mar 2011
This is part of a more general problem that there is a bug report or technical solution for (that I'd have to locate.) If you use matlabFunction() or inline() to convert symbolic expressions to Matlab, then some calls (such as ln) do not get translated to their Matlab equivalents, and others (such as Ei) have no Matlab equivalents to be translated to.
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!