I am trying to convert extinction coefficient to refractive index.
Unrecognized function or variable 'k_vec'.
Error in KramersKroigRelations (line 12)
n_vec = zeros(size(k_vec));
I tried to set up k_vec to indicate the refractive indices.
k_vec to refractive indices
data = readtable('extinctionSpectrum.txt');
n_vec = zeros(size(k_vec));
n_real = 1 + (2/pi)*integral(@(w_prime) w_prime.*k./(w_prime.^2 - w.^2), 0, Inf, 'PrincipalValue', true);
n_imag = (2/pi)*integral(@(w_prime) w.*k./(w_prime.*(w_prime.^2 - w.^2)), 0, Inf, 'PrincipalValue', true);
n_vec(i) = n_real + 1i*n_imag;
plot(w, real(n_real), 'b-', w, imag(n_imag), 'r-');
xlabel('Wavelength (nm)');
ylabel('Refractive index');
legend('Real part', 'Imaginary part');