inception_
Newbie level 4
Hi,
I'm sure I'm not the first who ever asked about the problem of plotting a 3D farfield exported from CST MWS. However, since days I try to get a reasonable solution with mesh(), surf() and plot3() in Matlab. All of this does not work. I found a function that does the job: patternCustom(). But I do not have access to the Antenna Toolbox, so I want to plot it on my own. My question is: is there a way of plotting a 3D farfield exported from CST MWS in Matlab exploiting any "free" function like mesh(), surf() or plot3() (or maybe a function I do not know so far) to get a result as indicated below (click on link)?
https://de.mathworks.com/matlabcentral/answers/368054-3d-farfield-radiation-pattern
My idea was to use the following code:
I know there is a function called sph2cart(), but the coordinate system definition of CST MWS and Matlab is different, so I use my own transformation formulas. The plot3() function just give me single data points, but I want the plot to look as with mesh() or surf().
I'm sure I'm not the first who ever asked about the problem of plotting a 3D farfield exported from CST MWS. However, since days I try to get a reasonable solution with mesh(), surf() and plot3() in Matlab. All of this does not work. I found a function that does the job: patternCustom(). But I do not have access to the Antenna Toolbox, so I want to plot it on my own. My question is: is there a way of plotting a 3D farfield exported from CST MWS in Matlab exploiting any "free" function like mesh(), surf() or plot3() (or maybe a function I do not know so far) to get a result as indicated below (click on link)?
https://de.mathworks.com/matlabcentral/answers/368054-3d-farfield-radiation-pattern
My idea was to use the following code:
Code:
%% init
clear all;
close all;
clc;
%% settings
file = "20200508_embedded_element_referenced.txt";
resample = 1; % take every xth value, 1 for no resampling
%% read data
data = dlmread(file, "", 2, 0);
theta = data(1:resample:end, 1); % values in degree
phi = data(1:resample:end, 2); % values in degree
ffdata = data(1:resample:end, 3); % directivity in dBi
%% transform spherical to cartesian coordinates
x = ffdata .* sind(theta) .* cosd(phi);
y = ffdata .* sind(theta) .* sind(phi);
z = ffdata .* cosd(theta);
%% plot farfield
figure;
plot3(x, y, z, 'x');
I know there is a function called sph2cart(), but the coordinate system definition of CST MWS and Matlab is different, so I use my own transformation formulas. The plot3() function just give me single data points, but I want the plot to look as with mesh() or surf().