how can delay give in nano or pico seconds ?

2 vues (au cours des 30 derniers jours)
Sarfaraz Ahmed
Sarfaraz Ahmed le 8 Jan 2019
Hi. I am giving delay to clock in mili, nano, pico seconds. Actually the clock timing value is let say 0.02 , if I attach variable transport delay block after the clock with 3m sec then my sampler sample the input at 0.023 which is fine. but when I give delay 3n sec or 3p sec then it makes the value same 0.02 (no affect of delay) or assume that small delay to 0.
Basically, I am working on nano and pico seconds. so it's very impportant to consider even small delay. How can I do this any one can help in this regard please ? I attached the the snap and delay code below:
function y fcn(count)
persistent p;
persistent j;
if isempty(p) % Initialization
p=0.3e-3;
%p=3e-9;
end
if isempty(j) % Initialization
j=-1;
end
step_size=0.1e-3 %% Initialization
%step_size=1e-9 %% Initialization
if(count<=j)
p=p - step_size;
j=j-1;
end
y = p;
Thanks
  2 commentaires
Jan
Jan le 8 Jan 2019
Modifié(e) : Jan le 8 Jan 2019
I do not understand, what your problem is.
x = 0.02 - 1e-9
fprintf('%.16g\n', x)
You see that the results differs from 0.02. Maybe you use disp to show the values? Then increase the number of displayed digits:
format long g
0.02 - 1e-9
This is not a more accurate calculation, but only less rounding for the display in the command window.
Sarfaraz Ahmed
Sarfaraz Ahmed le 9 Jan 2019
Thanks Jan. I will look by setting long format.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Clocks and Timers dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by