필터 지우기
필터 지우기

I am getting an error using interp1

조회 수: 5 (최근 30일)
Ambali Odebowale
Ambali Odebowale 2022년 2월 21일
댓글: Ambali Odebowale 2022년 12월 23일
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
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일
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개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by