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

10 Ansichten (letzte 30 Tage)
  1. Y=X/(X2+1)
  1 Kommentar
Manikanta Aditya
Manikanta Aditya am 8 Apr. 2024
Bearbeitet: Manikanta Aditya am 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

Melden Sie sich an, um zu kommentieren.

Antworten (2)

KSSV
KSSV am 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 am 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

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by