hi how can i evaluate the function below from x=1,x=2 into a step of 0.1 y=x/(x2+1)

10 views (last 30 days)
  1. Y=X/(X2+1)
  1 Comment
Manikanta Aditya
Manikanta Aditya on 8 Apr 2024
Edited: Manikanta Aditya on 8 Apr 2024
You can do this:
x = 1:0.1:2; % Define the range of x with a step of 0.1
y = x./(x.^2 + 1); % Evaluate the function
disp(x)
1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000
disp(y)
0.5000 0.4977 0.4918 0.4833 0.4730 0.4615 0.4494 0.4370 0.4245 0.4121 0.4000

Sign in to comment.

Answers (2)

KSSV
KSSV on 8 Apr 2024
x = 1:0.1:2; % Define the range of x with a step of 0.1
y = x./(x.^2 + 1); % Evaluate the function
plot(x,y)

Sam Chak
Sam Chak on 8 Apr 2024
syms x
y = eval('x/(x^2 + 1)') % <-- check if the function is correct
y = 
xa = 1; % start point of [xa ≤ x ≤ xb]
xb = 2; % final point of [xa ≤ x ≤ xb]
xs = 0.1; % step size
xval= xa:xs:xb % values of x from xa to xb
xval = 1x11
1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
y = subs(y, x, xval) % substitute the values of 'xval' into 'x'
y = 
plot(xval, y, '-o'), grid on, xlabel x, ylabel y

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!