Hhow to enhance smoothness of graph?

조회 수: 1 (최근 30일)
shiv gaur
shiv gaur 2022년 1월 23일
댓글: shiv gaur 2022년 1월 23일
function metal1
T2=1e-9:1e-10:1e-6;
for j=1:numel(T2)
t2 = T2(j);
p0 = 0.5;
p1 = 1;
p2 = 1.5;
TOL = 10^-8;
N0 = 100; format long
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t2) - f(p0,t2))/h1;
DELTA2 = (f(p2,t2) - f(p1,t2))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=3;
while i <= N0
b = DELTA2 + h2*d;
D = (b^2 - 4*f(p2,t2)*d)^(1/2);
if abs(b-D) < abs(b+D)
E = b + D;
else
E = b - D;
end
h = -2*f(p2,t2)/E;
p = p2 + h;
if abs(h) < TOL
%disp(p)
break
end
p0 = p1;
p1 = p2;
p2 = p;
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t2) - f(p0,t2))/h1;
DELTA2 = (f(p2,t2) - f(p1,t2))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=i+1;
end
if i > N0
formatSpec = string('The method failed after N0 iterations,N0= %d ');
fprintf(formatSpec,N0);
end
P(j)=abs(imag(p)*8.57e5);
% P(j)=real((p));
end
plot(T2,P)
end
%--------------------------------------------------------------------------------
function y=f(x,t2)
%t2=1e-9;
k0=(2*pi/0.6328)*1e6;
n1=1.521;
%n2=2.66;
n2=4.1-1i*0.211;
ns=1.512;
%n2=1.2-1i*7;
nc=1;
k1=k0*sqrt(n1.^2-x.^2);
k2=k0*sqrt(n2.^2-x.^2);
t1=2e-6;
m11= cos(t1*k1)*cos(t2*k2)-(k2/k1)*sin(t1*k1)*sin(t2*k2);
m12=(1/k2)*(cos(t1*k1)*sin(t2*k2)*1i) +(1/k1)*(cos(t2*k2)*sin(t1*k1)*1i);
m21= (k1)*cos(t2*k2)*sin(t1*k1)*1i +(k2)*cos(t1*k1)*sin(t2*k2)*1i;
m22=cos(t1*k1)*cos(t2*k2)-(k1/k2)*sin(t1*k1)*sin(t2*k2);
%gs=(x.^2-ns.^2)*k0.^2;
%gc= (x.^2-nc.^2)*k0.^2;
gs=k0*sqrt(x.^2-ns.^2);
gc=k0*sqrt(x.^2-nc.^2);
y= 1i*(gs*m11+gc*m22)-m21+gc*gs*m12 ;
end
This is the running program but we are not getting the fine graph just like that in the attach file.
  댓글 수: 9
shiv gaur
shiv gaur 2022년 1월 23일
p is the root of the equation and where to write these sgolayfilt (): in program
shiv gaur
shiv gaur 2022년 1월 23일
how to use sgolayfilt(P,31); in this program to smooth the graph

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by