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

10 次查看(过去 30 天)
  1. Y=X/(X2+1)
  1 个评论
Manikanta Aditya
Manikanta Aditya 2024-4-8
编辑:Manikanta Aditya 2024-4-8
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

请先登录,再进行评论。

回答(2 个)

KSSV
KSSV 2024-4-8
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 2024-4-8
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

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by