what is the error in this program

4 次查看(过去 30 天)
for k=5:5:50
z=zeros(1,length(k));
Pr1=(10*0.75*0.75*(exp(-0.984*k/cos(pi/36)))*0.01*cos(pi/36)/((2*pi*k.^2)*(1-cos(pi/3))));
%Pr_dbm1(k)=10*log10(Pr1)
z(k)=10*log10(Pr1);
plot(k,z)
xlabel('distance')
ylabel('Power')
title('Rcvd Power vs Distance')
%Pr1
end

采纳的回答

Stephen23
Stephen23 2019-9-5
k = 5:5:50;
Pr1 = (10*0.75*0.75*(exp(-0.984*k./cos(pi/36))) .* 0.01 .* cos(pi/36) ./ ((2*pi*k.^2)*(1-cos(pi/3))));
z=10.*log10(Pr1);
plot(k,z,'-*')
untitled.png

更多回答(1 个)

Alex Mcaulley
Alex Mcaulley 2019-9-5
There is no error in your code, the problem is that it doesn't do whatt you want. I guess you want something like this (without loops):
k=5:5:50;
Pr1=(10*0.75*0.75*(exp(-0.984*k/cos(pi/36)))*0.01*cos(pi/36)./((2*pi*k.^2)*(1-cos(pi/3))));
%Pr_dbm1(k)=10*log10(Pr1)
z=10*log10(Pr1);
plot(k,z)
xlabel('distance')
ylabel('Power')
title('Rcvd Power vs Distance')

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by