フィルターのクリア

performing a command for the firts time

2 ビュー (過去 30 日間)
Meisam
Meisam 2012 年 3 月 1 日
Hi, The question is that How should I ask matlab to perform a coomand for the first time i reach it. to make it clear I have a times(second) like this: 4 4.2 4.4 4.6 4.8 5 5.2 5.4 5.6 5.8....... and I have ti=5.1 s and I want to say that
for i=1:100 if for the first time t>=ti statements end end so the statemenst should be performed just in 5.2 and not for others.
  1 件のコメント
Meisam
Meisam 2012 年 3 月 1 日
sorry for bad spelling, this keyboard sometimes does not work well, it is Command not coomand

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

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 3 月 1 日
ti = 5.1;
for i1 = 1:numel(t)
if t(i1) > ti
% your statements
break;
end
end
or
t = [4 4.2 4.4 4.6 4.8 5 5.2 5.4 5.6 5.8] ;
ti = 5.1;
dt = t-ti;
ttest = abs(dt - min(abs(dt))) < eps*100;
for j1 = 1:numel(ttest)
if ttest(j1)
% your statements
end
end
  1 件のコメント
Meisam
Meisam 2012 年 3 月 1 日
great,
thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by