how can delay give in nano or pico seconds ?

6 次查看(过去 30 天)
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 个评论
Jan
Jan 2019-1-8
编辑:Jan 2019-1-8
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 2019-1-9
Thanks Jan. I will look by setting long format.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by