フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to get the values of f at different x

2 ビュー (過去 30 日間)
Kazeem Issa
Kazeem Issa 2019 年 2 月 13 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
how can I get f(k+1) reference to values of x, although if I remove range of x, I will get the answer interms of x but I need the values not in variable forms. Here is the code
syms x
P(1)=x^0;
P(2)=x;
for n=1:d
P(n+2)=expand(((2*n+1)/(n+1))*x*P(n+1)-(n/(n+1))*P(n));
end
for k=0:d
a=0;b=1;N=6;
x = a:0.1:b;
f(k+1)= exp(x).*P(k+1); % how can I get this reference to values of x
end

回答 (1 件)

Yasasvi Harish Kumar
Yasasvi Harish Kumar 2019 年 2 月 13 日
Try using the subs command to substitute values of x in your expression.
syms x
P(1)=x^0;
P(2)=x;
for n=1:d
P(n+2)=expand(((2*n+1)/(n+1))*x*P(n+1)-(n/(n+1))*P(n));
end
for k=0:d
f(k+1)= exp(x).*P(k+1);
a=0;b=1;N=6;
x = a:0.1:b;
t(k+1) = subs(f(k+1),x); % Actual value
end
  1 件のコメント
Kazeem Issa
Kazeem Issa 2019 年 2 月 13 日
It doesn't work/run using t(k+1)
Regards

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by