Error using integral (line 85). A and B must be floating-point scalars.
1 view (last 30 days)
Show older comments
Oleg Primachenko
on 27 Nov 2015
Commented: Oleg Primachenko
on 27 Nov 2015
I=.3*pi:.1*pi:.8*pi;
plot(I,sin(I)./I+integral(@(t) (1-cos(t))./t, 0, I)
Error using integral (line 85)
A and B must be floating-point scalars.
0 Comments
Accepted Answer
Walter Roberson
on 27 Nov 2015
integral() is not designed to integrate to a list of different values.
You can use arrayfun() to integrate to each of the values in turn, having it do all the previous work all over again. Or you can break it up into intervals and integrate over each of them and use cumsum() to get the list of values.
targets = [0 I];
cumsum( arrayfun( @(IDX) integral(@(t) (1-cos(t))./t, targets(IDX), targets(IDX+1)), 1:length(targets)-1 ) )
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!