How to shifting or move the time axis to the left in a MATLAB plot.
조회 수: 43 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Walter Roberson
2022년 1월 19일
Pass the coordinates of the independent axes to plot() before the dependent coordinates -- plot(x,y)
댓글 수: 4
Walter Roberson
2022년 1월 24일
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
2022년 1월 25일
댓글 수: 3
Walter Roberson
2022년 1월 26일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!