Is there a quick way to shift real data points?

6 ビュー (過去 30 日間)
Real Name
Real Name 2017 年 2 月 9 日
回答済み: Jayaram Theegala 2017 年 2 月 17 日
I have discrete data points I collected with respect to time. I want to take the difference between a shift in time. In other words, shift all the data by some time and then subtract the original data from it. (ignoring points not in both graphs)
For example, this is what I'm trying to do. I doesn't work but I think you know what I mean:
LabResponse = csvread('scope_4.csv', 2, 0);
time = LabResponse(:,1);
delayedT = LabResponse(:,1) - 0.0005;
output = LabResponse(time, 2)-LabResponse(delayedT,2);

採用された回答

Jayaram Theegala
Jayaram Theegala 2017 年 2 月 17 日
"delayedT" variable in the above MATLAB script can have decimal values, and if you try to use it for indexing with "LabResponse" variable, MATLAB will throw the "Subscript indices must either be real positive integers or logicals." error.
You may find the following code to be useful for achieving what you are trying to do:
if true
data = rand(1,10);
time = 1:10;
LabResponse = [time', data'];
shift = 2; %setting the shift to two time
output = LabResponse(1:length(LabResponse)-shift, 2) - LabResponse(shift+1:length(LabResponse),2)
end
As you can see from the "output" variable, its length is 8 (total length - shift = 8) and also, output(1) = data(1) - data(1+shift). I hope this helps.

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by