Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Shifting data
Replies: 2   Last Post: Feb 18, 2010 9:49 AM

 Messages: [ Previous | Next ]
 Ben Posts: 6 From: Netherlands Registered: 2/18/10
Re: Shifting data
Posted: Feb 18, 2010 9:49 AM

Dear Jan Simon,

Thanks for your reply. I'm sorry for my explanation. But I have the solution.

function [x] = FuncFindTrig(signal, trig)

% Find point closest to trigger point (trig)

% find point closest to trig
B1 = abs(signal-trig);
[C,D] = min(B1);

% when first point is bigger than trig, use second point
B2 = signal>trig;

% sig1 = x>trx;
sig2 = B2(2:end) - B2(1:end-1);
B3 = find (sig2==1);

if B3(1)==1;
B3(1)= B3(2)+1;
else B3(1)=B3(1)+1;
end

UPx = B3(1);
LPx = B3(1)-1;
UPy = signal(UPx);
LPy = signal(LPx);

% a = delY/delX;
a = (UPy-LPy)/(UPx-LPx);
b = signal(LPx);

% y = ax+b;
x = LPx+(trig-b)/a;
end

This is my solution:
% shifting figures to same point xA and xB must be zero
Bsize= size(B);

% B2=B(xBtrig:end)
t= 1-xBtrig:1:Bsize(2)-xBtrig;

figure;
plot(t,B)
FuncHorline(trig);
FuncVertline(0);

It is of course only the display of the figure that needed to be changed, not the data as such.

Date Subject Author
2/18/10 Ben
2/18/10 Jan Simon
2/18/10 Ben