Amrita Pati
Ansys Employee

Hi Prabha,

We can collect the fields from the analysis group rather than from the monitor. I would try something like this:

theta = linspace(-90,90,100); 
phi = 0;
Theta = meshgridx(theta,phi);
Phi = meshgridy(theta,phi);

XY_halfspace = getresult("scat_ff","XY_halfspace"); #getting the result from the analysis group combining farfield from 5 monitors
ux = XY_halfspace.ux;
uy = XY_halfspace.uy;
E2_upper = XY_halfspace.E2_upper; #E2 is intensity
plot(theta, farfieldspherical(E2_upper,ux,uy,theta,phi) ,"theta", "E^2", "E^2 at phi=0");

I just modified the code you shared here. So, I haven't actually tested it. Please feel free to let me know if you see any issues. Thank you!

Regards,
Amrita