Clear Filters
Clear Filters

Signal Analyser - Time Values Query for Re-Sampling

3 views (last 30 days)
Hi,
I am attempting to re-sample a signal (and array of signals if possible) in the Signal Analyser app. The catpured data is imported from ANSYS which has a variable step solver. I have the captured signals (i.e., volume_03) and the time signal (t) in the workspace, all are 574x1 doubles. When I go to change the x-axis to "Time Values" and select the time signal in the worspace I encounter an error. Can a time signal be selected in this manner?
Thanks in advance
Patrick

Accepted Answer

Cris LaPierre
Cris LaPierre on 26 Aug 2022
It appears the time values you are using contain duplicate values (or maybe NaNs?), which is not allowed. However, yes, you can specify a variable as your time values.
See this page, which says:
Use this option when you know the time value corresponding to each sample. Specify the time values using a MATLAB expression or the name of a variable in the MATLAB workspace.
The Time Values can be stored in a numeric vector with real time values expressed in seconds. The values must be unique and cannot be NaN, but they need not be uniformly spaced. The vector must have the same length as the signal.
The time values can also be stored in a duration array. The values must be unique and cannot be NaN, but they need not be uniformly spaced. The array must have the same length as the signal.
The time values can also be entered as a MATLAB expression. The expression must specify an array with the same length as the signal. The values must be unique and cannot be NaN, but they need not be uniformly spaced. Valid examples include:
  • (0:length(s)-1)'/Fs, where s is the signal and Fs is a scalar in the workspace representing a sample rate.
  • linspace(2,2.5,length(s))', where s is the signal.
  • minutes(0:15)', equivalent to taking measurements every minute for 15 minutes.
  • [0:10 20:30], equivalent to taking two sets of measurements at 1 Hz with a long pause between the sets.
In all cases, the app derives a sample rate from the time values and displays it in the Time column of the Signal table. An asterisk preceding the sample rate indicates that the signal is nonuniformly sampled.
  3 Comments
Cris LaPierre
Cris LaPierre on 26 Aug 2022
Though that may explain what is happening, what is displayed on the screen vs what is stored in memory are different. MATLAB defaults to displaying only 4 decimal places for readability. Resolution will be determined by your data type. The default data type for numbers in MATLAB is a double, which can capture between 15 and 16 decimal places resolution. Use the eps function to see what it is on your system.
You can use the format function to change how many decimal places are displayed.
PB75
PB75 on 30 Aug 2022
Hi Cris,
Thanks for your help. From what I can make out now, as the data is captured in ANSYS with a variable rate solver, the simulation time step reduces to a region of the simulation where MATLAB flags duplicate values when processing. Any time value that is the same to 4 decimal places will flag. As you mentiond I can change the decimal places displayed with the format function. However, I do not know how to address changing the decimal places for the data held in the memory. For now I have used code to find duplicate values in the simulation time signal before I do any post processing and change them manually. A bit labour intensive, but a work around.
% indices to unique values in column 1
[~, ind] = unique(Data(:, 1), 'rows');
% duplicate indices
duplicate_ind = setdiff(1:size(Data, 1), ind);
% duplicate values
duplicate_value = Data(duplicate_ind, 1);
Thanks

Sign in to comment.

More Answers (0)

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!