フィルターのクリア

What is the problem with this for loop?

1 回表示 (過去 30 日間)
kintali narendra
kintali narendra 2016 年 6 月 5 日
編集済み: per isakson 2016 年 6 月 6 日
deltaK values are should be "zero" for clock time of 0 - 0.999 sec but its giving the values of 0.1.Please help to solve the issue.
function [Out] = LMAImplementation_Motor(In)
persistent eWithNoChange eWithDeltaL eWithDeltaK
e = In(1);
L = In(2);
K = In(3);
Clock = In(4);
clock = int64(Clock)
for clock = 0.000:0.999
deltaK = 0; deltaL = 0;
eWithNoChange(end+1) = e;
sizeofeWithNoChange = size(eWithNoChange);
end
for clock = 1.000:1.999
deltaL = L*0.1; deltaK = 0;
eWithDeltaL(end+1) = e;
sizeofeWithDeltaL = size(eWithDeltaL);
end
for clock = 2.000:2.999
deltaL = 0; deltaK = K*0.1;
eWithDeltaK(end+1) = e;
sizeofeWithDeltaK = size(eWithDeltaK);
end
deltaK
deltaL
Out = [deltaL,deltaK,Clock];
end
I don't understand why the deltaK values is 0.1 even when the clock values in between 0 and 0.999.

回答 (1 件)

Roger Stafford
Roger Stafford 2016 年 6 月 5 日
For each of the for-loops ‘clock’ can take only one value. For example, with "for clock = 1.000:1.999", clock can only be 1.000, since the default step size is 1. I think you meant "for = 1.000:0.001:1.999".
  4 件のコメント
kintali narendra
kintali narendra 2016 年 6 月 5 日
Roger Stafford I made the above modification but there is no improvement. It is still the same
Roger Stafford
Roger Stafford 2016 年 6 月 5 日
You are not using 'clock' anywhere in your for-loops. Your 'e' is zero, so you are stretching 'eWithNoChang' out in long vectors of zeros and nothing else is accomplished. You had better stop and rethink what it is you are trying to do.

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

カテゴリ

Help Center および File ExchangeClocks and Timers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by