Prev: plotting
Next: dpsk simulink model
From: Ben on 17 Feb 2010 23:02 Hello, I want to start two graph's at the same y-value (trig) independent of there corresponding x-value so I can compare those graph's. So I've made a function which calculates the x-value of this y-value by interpolation. This gives me the exact x-value of the point of intersection. In a next step I want to plot both graphs with the intersection point in both graphs at the same x-value. For this step I would like to shift the data from this (non-existing) interpolated intersect x-point. The problem is that this intersect x-value is between to measurement points and the question is whether and how it is possible to shift the data over the x-axis to a certain point. For example: Working with array G. The intersect point is between data point A(0.2, 1) and data point B(0.8, 2) The intersect point has coordinates (1.333,0.4) I want to shift array G in such a way that intersect point (y=0.4) will have a x=0.
From: Jan Simon on 18 Feb 2010 09:32 Dear Ben! > I want to start two graph's at the same y-value (trig) independent of there corresponding x-value so I can compare those graph's. > > So I've made a function which calculates the x-value of this y-value by interpolation. > This gives me the exact x-value of the point of intersection. > > In a next step I want to plot both graphs with the intersection point in both graphs at the same x-value. > For this step I would like to shift the data from this (non-existing) interpolated intersect x-point. > > The problem is that this intersect x-value is between to measurement points and the question is whether and how it is possible to shift the data over the x-axis to a certain point. > > For example: > Working with array G. > The intersect point is between data point A(0.2, 1) and data point B(0.8, 2) > The intersect point has coordinates (1.333,0.4) > > I want to shift array G in such a way that intersect point (y=0.4) will have a x=0. It is not getting clear to me.Why have A and B 2 dimensions?! If you interpolate A and B to get the intersection point, this is the solution already, because you have to interpolate A and B to get the intersection point. If you get the value for A(0.2, 1), this is actually the first point of the array you need. So I'm confused by the question. Jan
From: Ben on 17 Feb 2010 23:49 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.
|
Pages: 1 Prev: plotting Next: dpsk simulink model |