h=0.1;
t1=0:h:2*pi;
alpha=0.3;
f=@(x) sin(x);
for i=2:length(t1)
t=t1(i);
k=1/gamma(1-alpha);
w=@(s) (t-s).^(-alpha).*cos(s);
p(i)=integral(w,0,t);
end

1 件のコメント

TheStranger
TheStranger 2017 年 9 月 1 日
Hello Sameer. Sorry for the offtop, but have you tested, whether a vectorized version is faster than just looping? I tried "integral" function with "ArrayValued=1" and it turned out that it is 20% slower than just looping over the parameter, for example.

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2017 年 8 月 6 日

1 投票

alpha=0.3;
syms s t
w = int((t-s).^(-alpha).*cos(s), s, 0, t);
h=0.1;
t1=0:h:2*pi;
p = double(subs(w, t, t1));

1 件のコメント

Sameer Chikane
Sameer Chikane 2017 年 8 月 6 日
Thanks a lot. It worked!!!

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2017 年 8 月 6 日
編集済み: Andrei Bobrov 2017 年 8 月 6 日

0 投票

h=0.1;
t1=0:h:2*pi;
p = arrayfun(@(t)integral(@(s)(t-s).^-alpha.*cos(s),0,t),t1)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by