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

4 vues (au cours des 30 derniers jours)
Esther
Esther le 8 Avr 2024
  1. Y=X/(X2+1)
  1 commentaire
Manikanta Aditya
Manikanta Aditya le 8 Avr 2024
Modifié(e) : Manikanta Aditya le 8 Avr 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

Connectez-vous pour commenter.

Réponses (2)

KSSV
KSSV le 8 Avr 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 le 8 Avr 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

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by