/* This script plots contour level curves from near field data exported from AN-SOF. It is assumed that the near field has been computed on a plane Z = constant (parallel to the XY-plane). */ // Close opened figures xdel(winsid()); // Imaginary unit i = sqrt(-1); // Read CSV file with near field data (replace here the path and file name) [M, c] = csvRead('C:/AN-SOF/Efield.csv', ';', [], [], [], [], [], 3); // Capture X and Y grids where near field have been calculated X = unique(M(:,2)); Y = unique(M(:,3)); // Capture complex (Ex, Ey, Ez) field components Ex = matrix(M(:,6)+i*M(:,7), length(Y), length(X)); Ey = matrix(M(:,10)+i*M(:,11), length(Y), length(X)); Ez = matrix(M(:,14)+i*M(:,15), length(Y), length(X)); // Plot contour level curves figure(1); clf(1); title('Ex', 'fontsize', 3); xlabel('X', 'fontsize', 2); ylabel('Y', 'fontsize', 2); contour2d(X, Y, abs(Ex'), 10); // 10 levels. Replace with a vector [L1 L2 ...] p = gca(); // having the desired levels for the contour curves p.isoview = 'on'; set(p,"grid",[1 1]); p.children.children.thickness = 2; figure(2); clf(2); title('Ey', 'fontsize', 3); xlabel('X', 'fontsize', 2); ylabel('Y', 'fontsize', 2); contour2d(X, Y, abs(Ey'), 10); p = gca(); p.isoview = 'on'; set(p,"grid",[1 1]); p.children.children.thickness = 2; figure(3); clf(3); title('Ez', 'fontsize', 3); xlabel('X', 'fontsize', 2); ylabel('Y', 'fontsize', 2); contour2d(X, Y, abs(Ez'), 10); p = gca(); p.isoview = 'on'; set(p,"grid",[1 1]); p.children.children.thickness = 2; figure(4); clf(4); title('E-total', 'fontsize', 3); xlabel('X', 'fontsize', 2); ylabel('Y', 'fontsize', 2); contour2d(X, Y, sqrt(abs(Ex').^2+abs(Ey').^2+abs(Ez').^2), 10); p = gca(); p.isoview = 'on'; set(p,"grid",[1 1]); p.children.children.thickness = 2;