Contour plot for the external data
4 views (last 30 days)
Show older comments
Dear everyone,
I would like to ask you about contour plot or suitable tools for representing external data.
Enclosed is my "eField_Sample.txt" data, which include a electric field distribution on an z-plane.
In the file, 3 components of the E-filed are save in complex numbers form. Therefore, the amplitude should be E_total = abs (Ex + Ey+ Ez)
Here what I have tried so far in the Matlab
simData = importdata('eField_sample.txt'); % import data
x_val = simData.data(:,1); % x-coordinate
y_val = simData.data(:,2); % y-coordinate
z_val = simData.data(:,3); % z-cooridnate
E_x = complex(simData.data(:,4),simData.data(:,5)); % complex values of Ex
E_y = complex(simData.data(:,6),simData.data(:,7)); % complex values of Ey
E_z = complex(simData.data(:,8),simData.data(:,9)); % complex values of Ez
[X,Y] = meshgrid(x_val, y_val); % create a matrix of 2 coordinates
[Ex,Ey] = meshgrid(E_x, E_y); % create a matrix of 2 equivalen E-fields, I do not know how to include the Ez components
Eabs_xy = abs(Ex + Ey); % calculate the magnitude of the total field
contourf(X,Y,20*log(Eabs_xy)); %plot
The figure is plotted in dB scale to compare with output from my simulation. I included an example of the E-field from my simulation for comparison. Well they do not look similar to each other.
Could anyone help me how to solve this problem?
Thank you very much,
,
0 Comments
Accepted Answer
KSSV
on 15 Jan 2021
Edited: KSSV
on 15 Jan 2021
simData = importdata('eField_sample.txt'); % import data
x_val = simData.data(:,1); % x-coordinate
y_val = simData.data(:,2); % y-coordinate
z_val = simData.data(:,3); % z-cooridnate
E_x = complex(simData.data(:,4),simData.data(:,5)); % complex values of Ex
E_y = complex(simData.data(:,6),simData.data(:,7)); % complex values of Ey
E_z = complex(simData.data(:,8),simData.data(:,9)); % complex values of Ez
%%
nx = length(unique(x_val)) ;
ny = length(unique(y_val)) ;
%
X = reshape(x_val,nx,ny) ;
Y = reshape(y_val,nx,ny) ;
%
Ex = reshape(E_x,nx,ny) ;
Ey = reshape(E_y,nx,ny) ;
Eabs_xy = abs(Ex + Ey); % calculate the magnitude of the total field
contourf(X,Y,20*log(Eabs_xy)); %plot
2 Comments
More Answers (0)
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!