Undefined function 'pout2' for input arguments of type 'double'.
Show older comments
clc;
clear all;
Pa=9;
R=3;
beta=8;
N=4;
P0=0.3126;
q1= 0:1:12;
pout3=1-exp(-(((2^R)-1)/(P0))^(beta/2));
for j=1:length(q1)
k = floor((q1*N)/Pa);
for jj = 1:N-k-1
P(j,jj)=0;
pout1(j,jj)=1-exp(-(((2^R)-1)/(P(j,jj)))^(beta/2));
end
for l = N-k+1:N
PP(j,l)=((N*q1)-P0)/k;%ko;
pout2(j,l)=1-exp(-(((2^R)-1)/(PP(j,l)))^(beta/2));
end
end for j=1:length(q1)
outage_f(j)=((pout1(j,:)+sum(pout2(j,N-k+1:N))+ pout3)/N);
end
plot(q1,outage_f,'*y');
grid on;
xlabel('transmit power');
ylabel('outage probability');
We are getting the error as follows
Undefined function 'pout2' for input arguments of type 'double'. Error in the (line 23) outage_f(j)=((pout1(j,:)+sum(pout2(j,N-k+1:N))+ pout3)/N);
Pls help us
Answers (1)
Mischa Kim
on 29 Jan 2014
Hello Ashly, in your code
outage_f(j)=((pout1(j,:)+sum(pout2(j,N-k+1:N))+ pout3)/N);
pout2 is not defined because you never enter the corresponding for-loop. Also note that with
k = floor((q1*N)/Pa);
k is not a scalar but a vector.
9 Comments
Ashly Kurian
on 29 Jan 2014
Ashly Kurian
on 29 Jan 2014
Mischa Kim
on 29 Jan 2014
As a side note, consider using the debugger to track down bugs. Insert break points in the code via mouse clicks right next to code lines and hit [Run]. With [Continue] and [Step] you can let the debugger run to the next break point or only one more step at a time.

Ashly Kurian
on 29 Jan 2014
Mischa Kim
on 29 Jan 2014
q1 is a vector, therefore, k is one as well. Which is the reason the for-loop where pout2 should be computed is never executed. As a result, outage_f(j) cannot be calculated.
Ashly Kurian
on 29 Jan 2014
Mischa Kim
on 29 Jan 2014
I do not know what you need to solve and how you do it so I can only give you feedback on the syntax issues with your code. It seems k is supposed to be a scalar so I suggest you start there (currently it is a vector). I am positive you can get it done.
Ashly Kurian
on 29 Jan 2014
Edited: Ashly Kurian
on 29 Jan 2014
Ashly Kurian
on 29 Jan 2014
Categories
Find more on Operators and Elementary Operations 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!