Polarplot for loop with subplots

16 views (last 30 days)
hayden johns
hayden johns on 17 May 2021
Commented: hayden johns on 18 May 2021
t =(2*pi)/(1*10^100):(2*pi)/1000:2*pi; %theta
k = 1/2;
L = k*lambda; %Length
B = 2*pi/lambda; %Beta
E = (cos((B*L/2)*cos(t)) - cos(B*L/2))./(sin(t));
P = E.^2;
polarplot(t,P, 'Linewidth', 1.5) % to plot the P vs theta curve
title('Dipole Radiation Power (L = \lambda/2)', 'Fontsize', 10)
set(gca, 'Fontsize', 15)
I need to change the code so that k = [0.25, 0.5, 1, 1.4, 2, 2.5]
i then need to use a for loop to plot 6 different plots using subplot so that i can view and compare all 6 plots at once
I have tried so many different options, im not the best with matlab so any help would be great.
thank you

Accepted Answer

VBBV
VBBV on 17 May 2021
%if true
lambda = 1; t =(2*pi)/(1*10^100):(2*pi)/1000:2*pi; %theta; lambda = 1;
k = [0.25 0.5 1 1.4 2 2.5];
for i = 1:length(k)
L = k(i)*lambda; %Length
B = 2*pi/lambda; %Beta
E = (cos((B*L/2).*cos(t)) - cos(B*L/2))./(sin(t));
P = E.^2;
subplot(6,1,i)
polarplot(t,P, 'Linewidth', 1.5) % to plot the P vs theta curve
title('Dipole Radiation Power (L = \lambda/2)', 'Fontsize', 4)
set(gca, 'Fontsize', 4);hold on;
end

More Answers (0)

Categories

Find more on Polar 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!