Trapz abnormal behavior. Error:Subscript indices must either be real positive integers or logicals.

1 回表示 (過去 30 日間)
When I enter:
>> trapz(2,2)
ans =
0
When I enter:
>> trapz(2.2,2.2)
Subscript indices must either be real positive integers
or logicals.
Error in ipermute (line 23)
inverseorder(order) = 1:numel(order); % Inverse
permutation order
Error in trapz (line 73)
if ~isempty(perm), z = ipermute(z,perm); end
Why trapz is having trouble in such case?

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 24 日
What are you expecting with trapz(2.2,2.2)? to compute the integral along x, you will need at least 2 points
  2 件のコメント
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013 年 8 月 24 日
trapz(2,2) which yields 0 is two points?. The numerical integral should be zero. So I expect 0. If that was the case then it should fail also at trapz(2,2).
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 24 日
%(2,2) is one point with x=2 and y=2.
% tarpz(2,2) returns 0, but I'm not sure if it's computing an integral, even the expected result is 0.

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


Walter Roberson
Walter Roberson 2013 年 8 月 24 日
When you use trapz() and the second argument is a scalar, then you are invoking the behavior trapz(Y,DIM) where DIM is to be a dimension number, which must be a positive integer.

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by