Is there a quick way to shift real data points?
3 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!