Polarplot for loop with subplots

19 vues (au cours des 30 derniers jours)
hayden johns
hayden johns le 17 Mai 2021
Commenté : hayden johns le 18 Mai 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

Réponse acceptée

VBBV
VBBV le 17 Mai 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

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by