Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

I am plotting the only two variable by this command, plot(Ps11,​r1,'-*b','​linewidth'​,3); but showing that the ??? Error using ==> plot Data may not have more than 2 dimensions Error in ==> tw_df at 31 plot(Ps11,​r1,'-*b','​linewidth'​,3); please help me

1 Ansicht (letzte 30 Tage)
clear all;close all; clc;
Ps11=-10:2:10;Pr1=10;Pr2=10;No=10^(-2);Rth=1;
Omg_1=1;Omg_2=1;Omg_3=1;Omg_4=1;Omg_5=1;Omg_6=1;r1=zeros(1: length(Ps11));
for a=1:length(Ps11)
Ps1=Ps11(a);
Ps2=Ps1;
a1=(Ps1*Omg_1)/No;a2=(Pr1*Omg_2)/No;a3=a1*a2/(a1+a2);a4=No/(Ps1*Omg_5);
a5=(Omg_6*Ps2)/(Omg_5*Ps1);a6=2^(2*Rth);a7=(a6-1)/a3;a8=(a6/a3)+a4;
xL=0;xU=2000;n=10000;h=(xU-xL)/n;fvec1=zeros(1,n);fvec2=zeros(1,n);
for f=1:n+1
x=xL+f*h;
fvec1(f)=NumFun1(x,Ps1);
fvec2(f)=NumFun2(x,Ps1);
end
f1=0;
f2=0;
f3=0;
f4=0;
for j=2:2:n
f1=f1+fvec1(j);
f3=f3+fvec2(j);
end
for k=3:2:(n-1)
f2=f2+fvec1(k);
f4=f4+fvec2(k);
end
Iinterval_1=(h/3)*(fvec1(1)+4*f1+2*f2+fvec1(n+1));
Iinterval_2=(h/3)*(fvec2(1)+4*f3+2*f4+fvec2(n+1));
r1(a)=1-exp(-a4)*(Iinterval_1+Iinterval_2);
end
plot(Ps11,r1,'-*b','linewidth',3);
xlabel('Transmit Powers of both Users')
ylabel('Secrecy Outage probability')
legend('Analitycal, P_{R_1}=P_{R_2}=10 watt',3)
In this there are two functions
first function is:
function fun1=NumFun1(x,Ps1)
Pr1=10;No=10^(-2);Rth=1;
Omg_1=1;Omg_2=1;Omg_5=1;Omg_6=1;
Ps2=Ps1;
a1=(Ps1*Omg_1)/No;a2=(Pr1*Omg_2)/No;a3=a1*a2/(a1+a2);a4=No/(Ps1*Omg_5);
a5=(Omg_6*Ps2)/(Omg_5*Ps1);a6=2^(2*Rth);a8=(a6/a3)+a4;
fun1=(a4*exp(-a8*x))/(a5*x+1);
end
and second function is:
function fun2=NumFun2(x,Ps1)
Pr1=10;No=10^(-2);Rth=1;
Omg_1=1;Omg_2=1;Omg_5=1;Omg_6=1;
Ps2=Ps1;
a1=(Ps1*Omg_1)/No;a2=(Pr1*Omg_2)/No;a3=a1*a2/(a1+a2);a4=No/(Ps1*Omg_5);
a5=(Omg_6*Ps2)/(Omg_5*Ps1);a6=2^(2*Rth);a8=(a6/a3)+a4;
fun2=(a5*exp(-a8*x))/(a5*x+1)^2;
end
  1 Kommentar
Shashibhushan Sharma
Shashibhushan Sharma am 11 Aug. 2017
I got my problem and sole it myself. Problem is this only "r1=zeros(1: length(Ps11));" instead of this command we can keep correct command "r1=zeros(1, length(Ps11));" Thanks to KSSV to try to solve it.

Antworten (1)

KSSV
KSSV am 11 Aug. 2017
YOur Ps11 is 1X11 and r1 is n dimensional matrix.....

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by