How to shifting or move the time axis to the left in a MATLAB plot.
41 views (last 30 days)
Show older comments
I have a matlab plot with two signals. The time axis is slightly different on one. How can I shift or move the time axis on the one to the left in my MATLAB plot.
I have tried using "plot(xArray + amountToShift, yArray);". The fourth line in the code below becomed "plot(sum+3)". This will only move the signal vertically up and down on the plot? I need to move the signal right and left on the plot.
Below is code for the plot.
sum = A{:,5} + B{:,5} + C{:,5};% Only use colume 5 of the csv files
hold all
figure('DefaultAxesFontSize',10)%Plot font size
plot(sum);
hold all
plot(D{:,5});
hold all
grid on;
xlabel('Time (\mus)')
ylabel('Amplitude (db)')
%xlim([-4.52e-7 5.52e-6]);
%ylim([0 9]);
0 Comments
Answers (2)
Walter Roberson
on 19 Jan 2022
Pass the coordinates of the independent axes to plot() before the dependent coordinates -- plot(x,y)
4 Comments
Walter Roberson
on 24 Jan 2022
Your original question contained none of that information !!!
Do your files have a column which is relative time? Or is there a fixed frequency that applies to all of them, such that we can calculate relative time as (difference in index) divided by (frequency) ?
If your files contain multiple columns, are there multiple data columns? If so then should each one be aligned independently?
Are your data columns directly in dB, or is there a fixed multiplier to convert to dB, or does the dB need to be calculated from the power spectrum somehow ?
BP
on 25 Jan 2022
3 Comments
Walter Roberson
on 26 Jan 2022
There isn't much to it. Replace T with the name of your table. Replace "Amplitude" with the name of the table variable that holds the amplitudes. Replace "Seconds" with the name of the table variable that holds the seconds.
find(condition, 1) returns the first index where the condition is true.
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!