- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
overcome machine precision for picosecond scale time axis
6 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I am in optical telecommunications where the rates are really high: dozens of gigabauds per carrier.
I am trying to set a time axis at the picosecond scale.
I have Nsymb = 10,000 [symbols]
sent at the rate symbate = 32 [GBd]
yielding a symbol duration Tsymb = 31.25 [ps]
With Nsps = 2 [samples/symbol]
and Nsamp = 20,000 [samples]
When I create my axis and i check the parameters I get small inconsistencies and the time samples are not perfectly uniformly distributed (see the plot), can we overcome it? Thanks in advance,
best
Nsymb = 1e4;
Nsps = 2;
Nsamp = Nsymb*Nsps;
symbrate= 32e9;
Tsymb = 1/symbrate;
dt = Tsymb/Nsps;
fs = 1/dt;
Time = 0:dt:Nsamp*dt;
plot(diff(Time))
0 件のコメント
回答 (2 件)
Hassaan
2024 年 1 月 18 日
% Define your parameters
Nsymb = 1e4; % Number of symbols
Nsps = 2; % Samples per symbol
symbrate = 32e9; % Symbol rate [Symbols per second]
Tsymb = 1/symbrate; % Symbol duration [seconds]
dt = Tsymb/Nsps; % Time step [seconds]
Nsamp = Nsymb * Nsps; % Total number of samples
% Generate the time axis using linspace to avoid floating point errors
Time = linspace(0, (Nsamp-1)*dt, Nsamp);
% Verify the uniform distribution of the time samples
Time_diff = diff(Time); % Differences between consecutive time points
plot(Time_diff);
title('Difference between consecutive time points');
If you still find non-uniformities, this could be an artifact of how the plot is rendered or the precision limit of MATLAB's floating-point arithmetic. The non-uniformities might be so small that they're insignificant for practical purposes.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Feel free to contact me.
3 件のコメント
Hassaan
2024 年 1 月 18 日
編集済み: Hassaan
2024 年 1 月 18 日
@Louis Tomczyk I didn't copy paste but for the above code I used the parameters you specified as reference.
I am trying to set a time axis at the picosecond scale.
I have Nsymb = 10,000 [symbols]
sent at the rate symbate = 32 [GBd]
yielding a symbol duration Tsymb = 31.25 [ps]
With Nsps = 2 [samples/symbol]
and Nsamp = 20,000 [samples]
If it still does not answer your question let me know the specifics. Thank you.
Hassaan
2024 年 1 月 22 日
編集済み: Hassaan
2024 年 1 月 22 日
@Louis Tomczyk I hope it answers your query.
- Use linspace or colon operator carefully: When generating time vectors, linspace is preferred over the colon operator : because it is designed to handle issues related to floating-point arithmetic more gracefully by calculating the interval directly.
- Scaling: Work with time units that are more numerically stable. For example, instead of working in seconds, you might choose to work in units of nanoseconds or microseconds during calculations and then convert back to seconds only when necessary.
- Reduce range: If possible, reduce the range of your data to avoid very large numbers. For example, you might center your time axis around zero or a relevant event.
- Double precision: MATLAB uses double-precision floating-point numbers by default, which should be sufficient for picosecond precision. Ensure that all operations are carried out in double precision, and avoid converting to single precision or integers.
- Arbitrary precision libraries: For calculations that require precision beyond what double-precision floating-point numbers can provide, consider using arbitrary precision libraries such as the Multiple Precision Toolbox for MATLAB.
- Symbolic Math Toolbox: For operations that need exact representations, use MATLAB's Symbolic Math Toolbox, which can represent numbers with arbitrary precision and perform symbolic calculations.
% Define your parameters
Nsymb = 1e4; % Number of symbols
Nsps = 2; % Samples per symbol
symbrate = 32e9; % Symbol rate [Symbols per second]
Tsymb = 1/symbrate; % Symbol duration [seconds]
% Since we are working with picoseconds, convert symbol duration to picoseconds
Tsymb_ps = Tsymb * 1e12; % Symbol duration [picoseconds]
% Time step in picoseconds
dt_ps = Tsymb_ps/Nsps; % Time step [picoseconds]
% Total number of samples
Nsamp = Nsymb * Nsps;
% Generate the time axis using linspace to avoid floating point errors, in picoseconds
Time_ps = linspace(0, (Nsamp-1)*dt_ps, Nsamp);
% Verify the uniform distribution of the time samples
Time_diff_ps = diff(Time_ps); % Differences between consecutive time points in picoseconds
% Convert back to seconds for plotting if necessary
Time_diff = Time_diff_ps * 1e-12;
% Now plot the differences
plot(Time_diff);
title('Difference between consecutive time points');
xlabel('Sample Number');
ylabel('Time Step Difference [s]');
In this revised code, all time calculations are performed in picoseconds to minimize numerical precision issues. The final plot displays the differences in seconds for interpretability, but the calculations are more stable because they avoid extremely small numbers.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Feel free to contact me.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!