フィルターのクリア

How do I plot a univariate integral?

1 回表示 (過去 30 日間)
Tatte Berklee
Tatte Berklee 2020 年 8 月 4 日
回答済み: Alan Stevens 2020 年 8 月 7 日
I am the following code, and I am trying to PLOT below integral over some positive real numbers's range x:
[p,S] = polyfit(x, y, 6);
fun = @(x) x/(p(1,1)*x.^6+p(1,2)*x.^5+p(1,3)*x.^4+p(1,4)*x.^3+p(1,5)*x.^2+p(1,6)*x+p(1,7)).^2;
exp = integral(fun,0,Inf,'ArrayValued',true);
Is there away I can plot the function, FUN, and with the integration?
I looked at cumtrapz, but I don't understand how it would work with a univariate integral case?
Can someone help?!

採用された回答

Alan Stevens
Alan Stevens 2020 年 8 月 7 日
Like this (you will need to replace my arbitrary polynomial with your own):
% Arbitrary polynomial
p = [2 1 -1 3 1 -1 5];
fun = @(x) x./(p(1,1)*x.^6+p(1,2)*x.^5+p(1,3)*x.^4+p(1,4)*x.^3+p(1,5)*x.^2+p(1,6)*x+p(1,7)).^2;
x = 0:0.01:2;
y = fun(x);
yint = zeros(size(x));
for i = 1:length(x)
yint(i) = integral(fun,0,x(i),'ArrayValued',true);
end
plot(x,y,x,yint)
xlabel('x'),ylabel('y')
legend('function','integral')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by