Importing data from HFSS and ploting in matlab

I designed a dipole in HFSS and exported the polar radiation pattern in csv format to matlab. now, i need help on how to plot the data and get the same result as HFSS. I also attached the raw csv format.

 採用された回答

Dan Klemfuss
Dan Klemfuss 2017 年 11 月 18 日

2 投票

Good Evening Mordecai. The following code ingests and plots the data in a figure for each Phi angle. Please let me know if you have any questions.
[num, txt] = xlsread('pat.csv');
theta_polar_deg = num(:,1);
theta_polar_rad = deg2rad(theta_polar_deg);
for i = 1:length(txt-1)
figure('Name',txt{i},'NumberTitle','off','MenuBar','none');
Gain = num(:,i);
polarplot(theta_polar_rad, Gain,'r')
rlim([min(Gain)-5 max(Gain)+5]);
ax = gca;
ax.RTick = [-38 -26 -14 -2];
ax.ThetaDir = 'clockwise';
ax.ThetaZeroLocation = 'top';
plotTitle = sprintf('Radiation Pattern %d',i);
title(plotTitle)
end

7 件のコメント

Mordecai Raji
Mordecai Raji 2017 年 11 月 18 日
Hi DRK, thanks for your help but i got this error Undefined operator '-' for input arguments of type 'cell'. Error in mathelp (line 7) for i = 1:length(txt-1)
help me out! thanks
Dan Klemfuss
Dan Klemfuss 2017 年 11 月 19 日
Good evening. I accidentally added the -1 inside the parenthesis, it should have been for i = 1:length(txt)-1. Please try the updated code below:
[num, txt] = xlsread('pat.csv');
theta_polar_deg = num(:,1);
theta_polar_rad = deg2rad(theta_polar_deg);
for i = 1:length(txt)-1
figure('Name',txt{i},'NumberTitle','off','MenuBar','none');
Gain = num(:,i);
polarplot(theta_polar_rad, Gain,'r')
rlim([min(Gain)-5 max(Gain)+5]);
ax = gca;
ax.RTick = [-38 -26 -14 -2];
ax.ThetaDir = 'clockwise';
ax.ThetaZeroLocation = 'top';
plotTitle = sprintf('Radiation Pattern %d',i);
title(plotTitle)
end
Mordecai Raji
Mordecai Raji 2017 年 11 月 21 日
Hi, i got this result. i have tried tweaking it but can't get something close. You gotta help me please!
Dan Klemfuss
Dan Klemfuss 2017 年 11 月 23 日
Hello Mordecai. I'm not sure why you got that result. I noticed in the CSV, column A has the theta values, so I modified the code to omit this column in the loop (that's why it is now "for i=2:length(txt)"). Please try the below code, I've attached an example of the output I am getting. Let me know if this works!
[num, txt] = xlsread('pat.csv');
theta_polar_deg = num(:,1);
theta_polar_rad = deg2rad(theta_polar_deg);
for i = 2:length(txt)
figure('Name',txt{i},'NumberTitle','off','MenuBar','none');
Gain = num(:,i);
polarplot(theta_polar_rad, Gain,'r')
rlim([min(Gain)-5 max(Gain)+5]);
ax = gca;
ax.RTick = [-38 -26 -14 -2];
ax.ThetaDir = 'clockwise';
ax.ThetaZeroLocation = 'top';
plotTitle = sprintf('Radiation Pattern %d',i-1);
title(plotTitle)
end
Dan Klemfuss
Dan Klemfuss 2017 年 11 月 23 日
P.S. This is the pat.csv file I was using, if it doesn't match the format you are using that may explain why you got a different result.
Mordecai Raji
Mordecai Raji 2017 年 11 月 24 日
Oh thanks, it works now. Great!
mahdi reshadat
mahdi reshadat 2018 年 1 月 11 日
編集済み: mahdi reshadat 2018 年 1 月 11 日
I have same project so i do your work but i give this error. What can i do?
Error is: Undefined function 'polarplot' for input arguments of type 'double'.
Error in Help (line 10) polarplot(theta_polar_rad, Gain,'r')

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

その他の回答 (1 件)

Mordecai Raji
Mordecai Raji 2018 年 1 月 12 日
編集済み: Mordecai Raji 2018 年 1 月 12 日

0 投票

Hi Mahdi, I think it's your MATLAB version. Instead use the function 'polar' instead of polarplot. I.e polar(theta_polar_rad, Gain, 'r')

1 件のコメント

mahdi reshadat
mahdi reshadat 2018 年 1 月 18 日
thank you. I use new version of MATLAB and it work.

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

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by