Contour plot for the external data

4 ビュー (過去 30 日間)
Hai Nguyen
Hai Nguyen 2021 年 1 月 15 日
コメント済み: KSSV 2021 年 1 月 15 日
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,
,

採用された回答

KSSV
KSSV 2021 年 1 月 15 日
編集済み: KSSV 2021 年 1 月 15 日
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 件のコメント
Hai Nguyen
Hai Nguyen 2021 年 1 月 15 日
Dear KSSV,
Great!! many thanks.
You miss the z-component but I included it in my code. Looks amazing.
Greetings,
KSSV
KSSV 2021 年 1 月 15 日
Use pcolor instead of contourf.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by