how to normalize output for plotting

3 views (last 30 days)
hello, i need to figure out how to normalize the putput thats getting plotted (largest value being one, rest scaled etc.)
i'm sure there's a function for it, but the few i have tried i dont have on my matlab (things like normc() etc)
here is code, and i'll include some output as well. the variable named "normalizedvector" does in fact seem to be normalized, but i cannot get it to plot correctly
i am trying to plot the radiation pattern of a dipole, and what gets spit out dosent seem correct
clc
clear
close all
addpath c:\antennas\ewa
beta=12.5664; %
eta=377;
l=.68;
a=.00002;
ker='a';
basis='d';
d=.001;
e=2.7128 %math constant
E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
output = pfield(l,a,E,ker,basis)
R=100 %meter
theta=0
d=.001683
f=1
A=zeros(1,101);
%differing vertical distance
for theta=0:.15708:pi %.01745
for k=1:1:101
A(k)=0
end
for k=1:1:101 %i have 101 slices
k;
cur=abs(output(k)); %grabs abs current at certain iteration
x=R-d*cos(theta); %defines changing distnce to point
Efield=(((1i*beta*eta*cur))/(4*pi*R))*e^((-1i)*beta*x)*e^(1i*beta*d)*sin(theta);
A(k)=abs(Efield)
A
%theta=theta+tand(d);
d=.001683+(.003366*(k-1)); %this sets the first distance half a sample up, then one slice distance up thereafter
end
%o=sum(A)
normalizedvector = (A- min(A)) / (max(A)-min(A));
o=sum(A)
%S=sum(normalizedvector,'all')
l=sum(normalizedvector(f))
%l=normalizedvector(f);
polarplot(theta,o,'*');
hold on
f=f+1;
A
normalizedvector
end
hold off
normalizedvector =
Columns 1 through 15
0 0.0425 0.0849 0.1270 0.1690 0.2106 0.2518 0.2926 0.3328 0.3724 0.4114 0.4496 0.4870 0.5235 0.5591
Columns 16 through 30
0.5937 0.6272 0.6596 0.6909 0.7208 0.7495 0.7769 0.8028 0.8273 0.8504 0.8719 0.8918 0.9102 0.9269 0.9419
Columns 31 through 45
0.9553 0.9670 0.9769 0.9851 0.9915 0.9961 0.9989 1.0000 0.9993 0.9967 0.9924 0.9863 0.9785 0.9688 0.9575
Columns 46 through 60
0.9444 0.9296 0.9131 0.8950 0.8752 0.8539 0.8752 0.8950 0.9131 0.9296 0.9444 0.9575 0.9688 0.9785 0.9863
Columns 61 through 75
0.9924 0.9967 0.9993 1.0000 0.9989 0.9961 0.9915 0.9851 0.9769 0.9670 0.9553 0.9419 0.9269 0.9102 0.8918
Columns 76 through 90
0.8719 0.8504 0.8273 0.8028 0.7769 0.7495 0.7208 0.6909 0.6596 0.6272 0.5937 0.5591 0.5235 0.4870 0.4496
Columns 91 through 101
0.4114 0.3724 0.3328 0.2926 0.2518 0.2106 0.1690 0.1270 0.0849 0.0425 0

Accepted Answer

VBBV
VBBV on 2 Dec 2020
o=A./sum(A)
%S=sum(normalizedvector,'all')
%l=sum(normalizedvector(f))
%l=normalizedvector(f);
polarplot(theta,o,'*');
Normalize o relative to A vector in your loop
  6 Comments
VBBV
VBBV on 4 Dec 2020
Can you share the snapshot of the two plots before and after multiplying pi/180 ?
neil whitesell
neil whitesell on 4 Dec 2020
firstone is what you originally gave me, it miiiiight be correct but has strange numbers like .01 and such under plot, mgiht be too low.
the secind one is after applying the pi/180

Sign in to comment.

More Answers (0)

Categories

Find more on Formatting and Annotation 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!