Tic-Toc Problem

4 次查看(过去 30 天)
cemsi888
cemsi888 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 CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by