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개)

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 Exchange에서 Programming에 대해 자세히 알아보기

질문:

2017년 8월 6일

댓글:

2017년 9월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by