フィルターのクリア

Info

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

what is wrong with the following code. I should have sent the full script. Sorry. On my macine the vector 'x' ranges from 0 to 10.1

1 回表示 (過去 30 日間)
Fred
Fred 2013 年 9 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
% trajetory 1
clf
m = .1; %n = .2;
% xx=1:10;y=[1 0 0 0 0 0 0 0 1 0];stem(xx,y)
%hold on
x(1) = 0; i = 1; y(1) = 1.1;
while x(i) <= 1.0
%x(i)= i;
x(i+1) = x(i) + 0.1;
y(i+1) = y(1) - m*x(i+1);
i = i+1;
end
plot(x,y,'r')
  3 件のコメント
Honglei Chen
Honglei Chen 2013 年 9 月 27 日
Could you explain what the issue is, why x range from 0 to 10.1 is an issue for you?
Jan
Jan 2013 年 9 月 27 日
@Fred: Please do not post multiple questions for the same problem. This confuses the readers and wastes their time, when they post an answer which has been given before in another thread.

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 9 月 27 日
Possibly you already had an array "x" in memory. Your code does not reinitialize "x" to be a single element long: if "x" already exists it just assigns to the first element of it and then goes ahead trying to use the full length of whatever "x" was there.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by