How to plot multiple function results depending on changed variable?
Show older comments
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 Comment
dpb
on 9 Jun 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.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink 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!