如何使用for循环matlab在单个图中绘制多个函数

时间:2017-10-07 21:40:58

标签: matlab plot electronics

我试图用阴影效果绘制路径损耗自由空间传播模型。对于该路径损失指数n,我想通过for循环更改其值,并希望在单个数字上显示所有不同的图。 所以,我正在使用以下代码,

clc
clear all

c = 3*10^8;  %in light speed in free space
fc = 28*10^9; % 28Ghz
lamda=c/fc;
do = 5; % free space refernce distance 1m
PLdo = 20*log(4*pi*do/lamda); 
%%in dB% Log-distance path loss model
%%path losss PL(d) at a particular location is random from paper

 for n = 2:5 
 d = 1:0.2:200; %T-R separation in meter
 PLd = PLdo + 10*n*log(d./do) + 6.9*randn(1,length(10*n*log(d./do)));
 end

figure
dis_dB = 10*log(d);
plot(dis_dB, PLd, '*')

但是,可能是它渲染一个情节。如下, enter image description here

如何根据n

的不同值渲染不同的绘图

1 个答案:

答案 0 :(得分:1)

使用hold on

clc
clear all

c = 3*10^8;  %in light speed in free space
fc = 28*10^9; % 28Ghz
lamda=c/fc;
do = 5; % free space refernce distance 1m
PLdo = 20*log(4*pi*do/lamda); 
%%in dB% Log-distance path loss model
%%path losss PL(d) at a particular location is random from paper

 for n = 2:5 
    d = 1:0.2:200; %T-R separation in meter
    PLd = PLdo + 10*n*log(d./do) + 6.9*randn(1,length(10*n*log(d./do)));
    dis_dB = 10*log(d);
    plot(dis_dB, PLd, '*'), hold on
 end