I am getting an error using interp1
Ältere Kommentare anzeigen
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 Kommentare
Matt J
am 21 Feb. 2022
Yes, and also only a fragment of the code. We don't know with what value of n, the function was called.
Ambali Odebowale
am 21 Feb. 2022
Image Analyst
am 21 Feb. 2022
Bearbeitet: Image Analyst
am 21 Feb. 2022
@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
am 22 Feb. 2022
Ambali Odebowale
am 22 Feb. 2022
Yordani
am 23 Dez. 2022
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
am 23 Dez. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Design Condition Indicators Interactively finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
