How to plot multiple function results depending on changed variable?

1 vue (au cours des 30 derniers jours)
I am wondering how to plot multiple function results depending on changed variable freq?
Starting inputs are r=1 and freq=5 000 000 000, and i want to show on one figure results from freq = 5*10^9 up to 9*10^9.
Does anyone have any ideas?
Thanks!
function [rcsdb] = rcs_circ_plate (r, freq)
eps = 0.000001;
lambda = 3.e+8 / freq;
index = 0;
for aspect_deg = 0.:.1:180
index = index +1;
aspect = (pi /180.) * aspect_deg;
if (aspect == 0 | aspect == pi)
rcs_po(index) = (4.0 * pi^3 * r^4 / lambda^2) + eps;
rcs_mu(index) = rcs_po(1);
else
val1m = lambda * r;
val2m = 8. * pi * sin(aspect) * (tan(aspect)^2);
rcs_mu(index) = val1m / val2m + eps;
end
end
rcsdb = 10. * log10(rcs_po);
rcsdb_mu = 10 * log10(rcs_mu);
angle = 0:.1:180;
plot(angle,rcsdb_mu)
grid;
xlabel ('\theta (deg)');
ylabel ('RCS (dB/m^2)');
axis tight
legend('f = 4 Ghz')
freqGH = num2str(freq*1.e-9);
end
  1 commentaire
dpb
dpb le 9 Juin 2021
Probably easiest is to move the plotting outside the function, return the data to be plotted from the function and call the function in a loop over the desired range of frequencies, plotting each result in turn in the loop.
See hold on and examples to put more than one set of data on a given axes.

Connectez-vous pour commenter.

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 9 Juin 2021
This is one of the easy ways how you can calculate and plot the results.
r = 1;
freq = 5e9:9e9;
for ii=1:numel(freq)
OUT(ii) = rcs_circ_plate (r, freq(ii));
end
plot(OUT) % Take what to be along the x axis
grid on
%
function [rcsdb] = rcs_circ_plate (r, freq)
eps = 0.000001;
lambda = (3.e+8)./ freq;
index = 0;
for aspect_deg = 0.:.1:180
index = index +1;
aspect = (pi /180.) * aspect_deg;
if (aspect == 0 | aspect == pi)
rcs_po(index) = (4.0 * pi^3 * r^4 / lambda^2) + eps;
rcs_mu(index) = rcs_po(1);
else
val1m = lambda * r;
val2m = 8. * pi * sin(aspect) * (tan(aspect)^2);
rcs_mu(index) = val1m / val2m + eps;
end
end
rcsdb = 10. * log10(rcs_po);
rcsdb_mu = 10 * log10(rcs_mu);
angle = 0:.1:180;
plot(angle,rcsdb_mu)
grid;
xlabel ('\theta (deg)');
ylabel ('RCS (dB/m^2)');
axis tight
legend('f = 4 Ghz')
freqGH = num2str(freq*1.e-9);
end

Plus de réponses (0)

Catégories

En savoir plus sur Simulink 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