%consts
vtransverse=590;
%origin
gamma=1;

%experimental data
load('C:Program FilesMatlabdatadata1Bb.dat');
load('C:Program FilesMatlabdatadata1rb.dat');
load('C:Program FilesMatlabdatadata1R.dat');
time=clock;starttime=(60*time(5)+time(6));

dr=0.001;%new advanced bracket
r = 0:dr:R;
n=(R/dr)+1;
root1=zeros(1,n);
root2=zeros(1,n);
M=10; %max degree of fitted polynom B

Bint=interp1(rb,Bb,r,'spline');
B=polyfit(r,Bint,M); %It ain't a simple MASSIVE
A=zeros(1,M+2);
for i=1:1:M+1
A(i)=B(i)/(M-i+3);
end
A(M+2)=0;

C=zeros(1,M+3);
for i=1:1:M+1
    C(i)=gamma*A(i);
end
C(M+2)=-1;


%Solving the first kind equation (root1)
for i=1:1:n
    rcur=r(i);
    Acur=polyval(A,rcur);
    const=rcur*(gamma*Acur+1);
    C(M+3)=-const;
    preroot=roots(C);
    for j=1:1:numel(preroot)
        if ((real(preroot(j))>0) && (real(preroot(j))<R) &&
(imag(preroot(j))==0))
            root1(i)=preroot(j);
        end
    end
    if (root1(i)==0)
        root1(i)=R;
    end
end

%Solving the second kind equation (root2)
for i=1:1:n
    rcur=r(i);
    Acur=polyval(A,rcur);
    const=rcur*(gamma*Acur-1);
    C(M+3)=-const;
    preroot=roots(C);
for j=1:1:numel(preroot)
        if ((real(preroot(j))>0) && (real(preroot(j))<R) &&
(imag(preroot(j))==0) && (real(preroot(j))>r(i)))
            if (root2(i)<real(preroot(j)))
                root2(i)=preroot(j);
            end
        end
    end
    if (root2(i)==0)
        root2(i)=r(i);
    end
end


time=clock;endtime=60*time(5)+time(6);
figure(5);plot(r,root1,'bluex',r,root2,'redx');grid on;title(num2str(endtime-
starttime));

Newconceptdataanalyze

  • 1.
    %consts vtransverse=590; %origin gamma=1; %experimental data load('C:Program FilesMatlabdatadata1Bb.dat'); load('C:ProgramFilesMatlabdatadata1rb.dat'); load('C:Program FilesMatlabdatadata1R.dat'); time=clock;starttime=(60*time(5)+time(6)); dr=0.001;%new advanced bracket r = 0:dr:R; n=(R/dr)+1; root1=zeros(1,n); root2=zeros(1,n); M=10; %max degree of fitted polynom B Bint=interp1(rb,Bb,r,'spline'); B=polyfit(r,Bint,M); %It ain't a simple MASSIVE A=zeros(1,M+2); for i=1:1:M+1 A(i)=B(i)/(M-i+3); end A(M+2)=0; C=zeros(1,M+3); for i=1:1:M+1 C(i)=gamma*A(i); end C(M+2)=-1; %Solving the first kind equation (root1) for i=1:1:n rcur=r(i); Acur=polyval(A,rcur); const=rcur*(gamma*Acur+1); C(M+3)=-const; preroot=roots(C); for j=1:1:numel(preroot) if ((real(preroot(j))>0) && (real(preroot(j))<R) && (imag(preroot(j))==0)) root1(i)=preroot(j); end end if (root1(i)==0) root1(i)=R; end end %Solving the second kind equation (root2) for i=1:1:n rcur=r(i); Acur=polyval(A,rcur); const=rcur*(gamma*Acur-1); C(M+3)=-const; preroot=roots(C);
  • 2.
    for j=1:1:numel(preroot) if ((real(preroot(j))>0) && (real(preroot(j))<R) && (imag(preroot(j))==0) && (real(preroot(j))>r(i))) if (root2(i)<real(preroot(j))) root2(i)=preroot(j); end end end if (root2(i)==0) root2(i)=r(i); end end time=clock;endtime=60*time(5)+time(6); figure(5);plot(r,root1,'bluex',r,root2,'redx');grid on;title(num2str(endtime- starttime));