Please help me, I can not solve problem
1 view (last 30 days)
Show older comments
clc
F=inline('X-e.^(-X.^2).*cos(X)'); % Function
X=1; % Starting Point
H=0.762; % Initial stepsize
EPS=0.0001; % Error Tolerance
%%PREPARE PLOT DATA
XP=X:H/100:X+7;YP=F(XP); (LINE13)
XP1=XP(1);XP2=XP(length(XP));
plot(XP,YP) %FUNCTION PLOT
grid on
hold on
plot([XP1 XP2],[0 0],'r')%PLOT OF X AXIS
xlabel('X');
ylabel('F(X)')
0 Comments
Answers (1)
Star Strider
on 4 Nov 2015
I believe you intended the exponential function when you wrote e.^(). The correct function is exp. Also, inline functions are going to disappear in a future MATLAB release, so I would use the anonymous function version instead:
F = inline('X-exp(-X.^2).*cos(X)'); % Inline Function
F = @(X) X-exp(-X.^2).*cos(X); % Anonymous Function
Your code works with these changes.
4 Comments
Star Strider
on 4 Nov 2015
My pleasure.
The sincerest form of thanks here on MATLAB Answers is to Accept the Answer that solves your problem.
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!