Info

この質問は閉じられています。 編集または回答するには再度開いてください。

this code shows error?

2 ビュー (過去 30 日間)
Dhines
Dhines 2013 年 2 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
S=S(1:f-1,f+1:length(S))
,,,, error:?? Index exceeds matrix dimensions.

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 2 月 26 日
Yes, that would occur if S is not two-dimensional and at least f-1 elements in the first dimension and length(S) elements in the second dimension.
Are you possibly trying to remove element #f from S? If so then
S(f) = [];
or
S = S([1:f-1, f+1:numel(S)]);

Jan
Jan 2013 年 2 月 26 日
Another guess:
Did you define "length" as a variable? Then "length(S)" might fail. Test this by:
dbstop if error
% start the code until Matlab stops at the problem. Then:
which length
  2 件のコメント
Dhines
Dhines 2013 年 2 月 26 日
it is variable sir. i defined it. length value is 50
Jan
Jan 2013 年 2 月 27 日
Defining "length" as a variable is a bad idea, because you cannot use the command length() afterwards. If "length" is 50, it has a single element only. Then "length(S)" must fail if S has any value different from 1.

Community Treasure Hunt

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

Start Hunting!

Translated by