Polarplot for loop with subplots

17 Ansichten (letzte 30 Tage)
hayden johns
hayden johns am 17 Mai 2021
Kommentiert: hayden johns am 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

Akzeptierte Antwort

VBBV
VBBV am 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

Weitere Antworten (0)

Kategorien

Mehr zu Polar Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by