Ansys Learning Forum › Forums › Discuss Simulation › Photonics › Exporting a large number of data sets into TXT from varFDTD › Reply To: Exporting a large number of data sets into TXT from varFDTD
Hi, sorry to be a pain with this haha. So I have rewritten my script as per your suggestion. This is what I now have:
Ex = real(getdata("E_field", "Ex"));
Ey = real(getdata("E_field", "Ey"));
Â
x = getdata("E_field", "x");
y = getdata("E_field", "y");
z = getdata("E_field", "z");
f = getdata("E_field", "f");
Â
x_max = length(x);
y_max = length(y);
z_max = length(z);
Â
lambda = (c/f) * 10^9;
Â
for (m=1:5){
fileName = num2str(lambda(m)) + "nm.txt";
E = sqrt(Ex(1:x_max, 1:y_max, 1:z_max, 1:m)^2 + Ey(1:x_max, 1:y_max, 1:z_max, 1:m)^2);
write(fileName, num2str(E(1:x_max, 1:y_max)), "overwrite");
}
It prints the E field data into a text file but it only seems to be doing it for the first data set (i.e. not iterating through the different wavelength values). Can you suggest where I could fix this?