Tic-Toc Problem

4 visualizzazioni (ultimi 30 giorni)
cemsi888
cemsi888 il 9 Gen 2023
Modificato: Image Analyst il 9 Gen 2023
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 Commento
Image Analyst
Image Analyst il 9 Gen 2023
Modificato: Image Analyst il 9 Gen 2023
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');

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by