how to plot graph using multiple variable

theta = 10 to 80;
da=1e-9:3e-7;
p=ds/da /ds/dx
na have three value 1.31 1.32 1.32
we have to plot(da,p) pl help how to plot graph using multiple variable plot three plot in one using loop pl
function y=s(x,na,,da)
l=6330*(10)^(-10);
k0=2*pi/l;
%na=1.340;
nc=1.33;
ec=nc^2;
ea=na^2;
nf=1.59;
ef=nf^2;
nm=0.064+1i*4;
em=nm^2;
ns=1.50;
es=ns^2;
df=0.5e-6;
dm=0.03e-6;
%da=0.06e-6;
np=1.340;
x=np*sin(theta);
kc=sqrt(x.^2-ec.*k0.^2);
ka=sqrt(ea.*k0.^2-x.^2);
kf=sqrt(ef.*k0.^2-x.^2);
km=sqrt(em.*k0.^2-x.^2);
ks=sqrt(x.^2-es.*k0^.2);
rfm=(kf-km)./(kf+km);
rms=(km-ks)./(ks+km);
rfa=(kf-ka)./(kf+ka);
rac=(ka-kc)./(ka+kc);
rsm=(ks-km)./(ks+km);
rmf=(km-kf)./(kf+km);
rfac=((rfa+rac.*exp(2*1i.*ka.*da))./(1+rfa.*rac.*exp(2*1i.*ka.*da)));
rmfac=((rmf+rfac.*exp(2*1i.*kf.*df))./(1+rmf.*rfac.*exp(2*1i*kf.*df)));
r=((rsm+rmfac.*exp(2*1i.*km.*dm))./(1+rsm.*rmfac.*exp(2*1i.*km.*dm)));
r1=conj(r);
y=r.*r1;
end

 Réponse acceptée

theta = linspace(10,80)*pi/180;
da=1e-9:3e-7;
na = [1.30 1.31 1.32 ] ;
P = zeros(length(na),length(theta)) ;
for i = 1:length(na)
P(i,:) = myfunc(theta,na(i),da) ;
end
plot(theta,P)
legend({'na = 1.30', 'na = 1.31', 'na = 1.32'})
% to plot(da,p)
function y=myfunc(theta,na,da)
l=6330*(10)^(-10);
k0=2*pi/l;
%na=1.340;
nc=1.33;
ec=nc^2;
ea=na^2;
nf=1.59;
ef=nf^2;
nm=0.064+1i*4;
em=nm^2;
ns=1.50;
es=ns^2;
df=0.5e-6;
dm=0.03e-6;
%da=0.06e-6;
np=1.340;
x=np*sin(theta);
kc=sqrt(x.^2-ec.*k0.^2);
ka=sqrt(ea.*k0.^2-x.^2);
kf=sqrt(ef.*k0.^2-x.^2);
km=sqrt(em.*k0.^2-x.^2);
ks=sqrt(x.^2-es.*k0^.2);
rfm=(kf-km)./(kf+km);
rms=(km-ks)./(ks+km);
rfa=(kf-ka)./(kf+ka);
rac=(ka-kc)./(ka+kc);
rsm=(ks-km)./(ks+km);
rmf=(km-kf)./(kf+km);
rfac=((rfa+rac.*exp(2*1i.*ka.*da))./(1+rfa.*rac.*exp(2*1i.*ka.*da)));
rmfac=((rmf+rfac.*exp(2*1i.*kf.*df))./(1+rmf.*rfac.*exp(2*1i*kf.*df)));
r=((rsm+rmfac.*exp(2*1i.*km.*dm))./(1+rsm.*rmfac.*exp(2*1i.*km.*dm)));
r1=conj(r);
y=r.*r1;
end

11 commentaires

shiv gaur
shiv gaur le 12 Jan 2022
how to write p in this manner in matlab then plot pl
p=ds/da /ds/dx
KSSV
KSSV le 12 Jan 2022
what is that actually?
shiv gaur
shiv gaur le 12 Jan 2022
thanks pl help to write p=ds/da /ds/dx means the change of s/change in da /change in s/change in x value
I have not seen such a differential so far.....that can be simplified to
p = ds/da*dx/ds
isn't it?
shiv gaur
shiv gaur le 12 Jan 2022
you have plot between da and p so sir you are request to plot between them
shiv gaur
shiv gaur le 12 Jan 2022
pl plot da vs p
shiv gaur
shiv gaur le 12 Jan 2022
pl plot da vs p not theta vs p pl help KSSV sir
shiv gaur
shiv gaur le 12 Jan 2022
pl help to plot between da vs ds /dx
shiv gaur
shiv gaur le 12 Jan 2022
pl plot da vs ds/ dx /ds /da
shiv gaur
shiv gaur le 12 Jan 2022
plot
shiv gaur
shiv gaur le 12 Jan 2022
you have not plot between da vs p

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2021b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by