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])

1 件のコメント

Ambali Odebowale
Ambali Odebowale 2022 年 2 月 22 日
編集済み: Ambali Odebowale 2022 年 2 月 22 日
@DGM Great! Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by