Hello guys,
I need to somehow extract part of the curved lines on picture below that goes from the red line to the max (or better from the intersection point to the max).
When I try to do it with the code Im running (provided below) I only get this
but I need something similair to picture below. I made this with excel where I generated points and then extracted only points I needed, but all this is done manualy and it's time consuming and not effective.
I'm new to the MATLAB, so if someone has a better idea how to generate the points or if there is an easier way to do this, please explain. Down below is the code that I'm working with. All the help will be appreciated.
%Math for generating the points
clcrn = 1.3;f = 0.5;ap = 0.2;po = 10;dx = 0.01;lambda = 0;gamma = -8;Kr = 51;Kr1 = 51;xa = (rn*(sin(Kr)))*-1;xb = rn*(sin(Kr1));ya = (xa*(tan(Kr)))+(rn/(cos(Kr)))-rn;%Straight line A
N = 100;xpA = xa - (0:N-1)*dx;xpA = xpA';xpA = sort(xpA);xpA = round(xpA,2);ypA = (xpA*tan(Kr))+(rn/(cos(Kr)))-rn;ypA = sort(ypA);ypA = round(ypA,2);%Straight line B
xpB = xb + (0:N-1)*dx;xpB = xpB';xpB = round(xpB,2);ypB = (-xpB*tan(Kr1))+(rn/(cos(Kr1)))-rn;ypB = round(ypB,2);%curved line
N1 = 5000; xk1 = xa + (1:N1)*dx;xk1 = round(xk1,2);xk1 = xk1';[c,d]= intersect(xk1,min(xpB));xk = xa +(1:d-1)*dx;xk = round(xk,2);xk = xk';yk = (sqrt((rn^2)-(xk.^2)))-rn;yk = round(yk,2);%connecting the lines together and creating the second one
X = [xpA;xk;xpB];Y = [ypA;yk;ypB];b = po-ap;x = X(1);X1 = X-x;Y1 = Y+b;X2 = X1+f;Y2 = Y1;%Intersection point between two lines
[Y1max,Y1ix] = max(Y1);[Y2max,Y2ix] = max(Y2);Xi = linspace(min([X1(Y1ix);X2(Y2ix)]), max([X1(Y1ix);X2(Y2ix)]), 20);Y1i = interp1(X1,Y1,Xi);Y2i = interp1(X2,Y2,Xi);Ydif = sort(Y2i-Y1i);Xq = interp1(Ydif, Xi, 0);Yq = interp1(Xi, Y1i, Xq);%Ploting the lines
figureplot(X1,Y1)hold onplot(X2,Y1)plot(Xq, Yq, 'sg', 'MarkerSize', 10)hold offtext(Xq, Yq, sprintf('\\uparrow\nX = %.4f\nY = %.4f',Xq,Yq), 'HorizontalAlignment','center', 'VerticalAlignment','top')%Extraction of the part of the lines I need (Problematic)
pe = numel(Xi)Yn1 = linspace(Yq,Y1max,pe/2)';Yn2 = linspace(Yq,Y1max,pe/2)';Yn2 = sort(Yn2,'descend');Yn = [Yn1;Yn2];xi = Xi(1);Xi1 = (Xi - xi)';Xi2 = (Xi1 + f);figureplot(Xi1,Yn)hold onplot (Xi2,Yn)
Best Answer