I have table of n and k vs frequency for TiO2 and I am trying to plot the corresponding dielectrics. Here is the code
function [frequency, dielectric_function] = plot_optical_constants_TiO2(n);
color_1 = [0.7411, 0, 0.1490];
color_2 = [0.9412, 0.2314, 0.1255];
color_3 = [0.9922, 0.5529, 0.2353];
color_4 = [0.9961, 0.8, 0.3608];
color_5 = [1, 1.0, 0.3980];
set(0,'defaultaxesfontsize',20);
set(0,'defaulttextfontsize',20);
set(0,'defaultaxeslinewidth',2);
set(0,'defaultlinemarkersize',10);
set(0,'DefaultFigureWindowStyle','docked');
set(0,'DefaultFigurePosition', [0 918 1120 840]);
N_w = 1000 ; % number of points in frequency span
N_k = 2000 ; % number of points in wavevector span
w_min = 5E12;
w_max = 1e15;
[w,k_r] = ndgrid( (linspace(w_min,w_max,N_w)) , (linspace(0,50E6,N_k)) );
e_TiO2 = dlmread('e_TiO2.txt');
w_Ge = e_TiO2(:,1);
e_TiO2 = e_TiO2(:,2) + 1i*e_TiO2(:,3);
e_TiO2_interp = interp1(w_Ge, e_TiO2, w);
dielectric_function = e_TiO2_interp;
frequency = w(:,1);
figure(4)
hh = plot(w(:,1), real(e_TiO2_interp(:,1)),w(:,1), imag(e_TiO2_interp(:,1)));
legend('\epsilon''_{TiO2}', '\epsilon''''_{TiO2}')
ylabel('Dielectric Function')
xlabel('Frequency, {\omega} (rad/s)')
set(hh(1), 'color', color_3)
set(hh(2), 'color', color_1)
xlim([5e12 1e15])
end
The error is pasted below:
Error using matlab.internal.math.interp1
Sample points must be unique.
Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in plot_optical_constants_TiO2 (line 24)
e_TiO2_interp = interp1(w_Ge, e_TiO2, w);

댓글 수: 8

Catalytic
Catalytic 2022년 2월 21일
편집: Catalytic 2022년 2월 21일
It looks like only a fragment of the error message was pasted.
Matt J
Matt J 2022년 2월 21일
Yes, and also only a fragment of the code. We don't know with what value of n, the function was called.
Ambali Odebowale
Ambali Odebowale 2022년 2월 21일
This is the complete error
Error using matlab.internal.math.interp1
Sample points must be unique.
Error in interp1 (line 188)
VqLite = matlab.internal.math.interp1(X,V,method,method,Xqcol);
Error in plot_optical_constants_TiO2 (line 24)
e_TiO2_interp = interp1(w_Ge, e_TiO2, w);
Image Analyst
Image Analyst 2022년 2월 21일
편집: Image Analyst 2022년 2월 21일
@Ambali Odebowale, did you see Matt's reply? It looks like you overlooked the last line "We don't know with what value of n, the function was called" So, how did you call it? Did you call it like
[frequency, dielectric_function] = plot_optical_constants_TiO2(1000)
or what? Again, what is n? You didn't just click the green run triangle without assigning a value of n did you? Because that would cause an error.
And where is n even used inside the function?
Voss
Voss 2022년 2월 22일
@Ambali Odebowale I think it will be useful if you attach the file e_TiO2.txt as well.
Ambali Odebowale
Ambali Odebowale 2022년 2월 22일
Here is the attached file. Thanks
Yordani
Yordani 2022년 12월 23일
Hello Ambali I would like to contact you to discuss this code designed for NFRHT. Can you give me your cell phone number or email? Thank you
Ambali Odebowale
Ambali Odebowale 2022년 12월 23일
odebowale.ambali.oa@gmail.com

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

 채택된 답변

DGM
DGM 2022년 2월 22일

0 개 추천

Strip out all the multiply-defined points:
color_1 = [0.7411, 0, 0.1490];
color_2 = [0.9412, 0.2314, 0.1255];
color_3 = [0.9922, 0.5529, 0.2353];
color_4 = [0.9961, 0.8, 0.3608];
color_5 = [1, 1.0, 0.3980];
set(0,'defaultaxesfontsize',20);
set(0,'defaulttextfontsize',20);
set(0,'defaultaxeslinewidth',2);
set(0,'defaultlinemarkersize',10);
set(0,'DefaultFigureWindowStyle','docked');
set(0,'DefaultFigurePosition', [0 918 1120 840]);
N_w = 1000 ; % number of points in frequency span
N_k = 2000 ; % number of points in wavevector span
w_min = 5E12;
w_max = 1e15;
[w,k_r] = ndgrid( (linspace(w_min,w_max,N_w)) , (linspace(0,50E6,N_k)) );
e_TiO2 = dlmread('TiO2.txt');
w_Ge = e_TiO2(:,1);
[w_Ge uidx] = unique(w_Ge);
e_TiO2 = e_TiO2(:,2) + 1i*e_TiO2(:,3);
e_TiO2 = e_TiO2(uidx);
e_TiO2_interp = interp1(w_Ge, e_TiO2, w);
dielectric_function = e_TiO2_interp;
frequency = w(:,1);
figure(4)
hh = plot(w(:,1), real(e_TiO2_interp(:,1)),w(:,1), imag(e_TiO2_interp(:,1)));
legend('\epsilon''_{TiO2}', '\epsilon''''_{TiO2}')
ylabel('Dielectric Function')
xlabel('Frequency, {\omega} (rad/s)')
set(hh(1), 'color', color_3)
set(hh(2), 'color', color_1)
xlim([5e12 1e15])

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

2022년 2월 21일

댓글:

2022년 12월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by