Is there a quick way to shift real data points?
조회 수: 2 (최근 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!