Tic-Toc Problem

10 ビュー (過去 30 日間)
cemsi888
cemsi888 2023 年 1 月 9 日
編集済み: Image Analyst 2023 年 1 月 9 日
Hello all,
I have defined time variable which I am reading from excel and would like to send ECU my signals (X and Y) according to time vector.
For Example :
when time <1 s
X=10%
Y=1
when time <2
X=11%
Y=1
and so ...
Normally my time vector is 90 sec however when I run my script it takes too long. Do you have any idea where I am making mistake? Could you advice me better solution ?
Best Regards
for i=2:100
tic
while toc<Time(i)
% time=Time(i);
X_inca=X(i);
Y_inca=Y_C(i);
end
end
  1 件のコメント
Image Analyst
Image Analyst 2023 年 1 月 9 日
編集済み: Image Analyst 2023 年 1 月 9 日
What does this mean "Time vector is 90 sec"? All we know is it has 100 elements, and we don't even know what the units are.
The loop will go as fast as it can. The loop as you have it there will probably get done within a few nanoseconds or microseconds. Not sure if you were thinking that loop would take around 90 seconds or more, but it won't unless you have a lot more time consuming stuff in there that you have not shown.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
save('camsi answers.mat', 'Time', 'X', 'Y_C');

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by