Bmax=2000000; %maximum available bandwidth for OFDMA
noise=1e-9; %fixed noise power is assumed
p_fix=0.01; %fixed transmit power is assumed
N_UE=[10 20 30 40 50 ];
N_SC=[60 70 80 90 100];
for it=1:2
for t= 1:length(N_UE)
for r = 1:length(N_SC)
throughput_E(t) = @(t) Bmax * log2(1 + p_fix(t)*gamma(t) / sum(p_fix(1:t-1) .* gamma(t) ));
overall_throughput_E(t) = sum(sum(throughput_E(t)));
output_E(t,r)=overall_throughput_E(t);
output_E(t)_it(t,r,it)=output_E(t,r);
end
end
end.
If i run the code i am getting
Error: File: Line: 12 Column: 12
The input character is not valid in MATLAB
statements or expressions.

 採用された回答

KSSV
KSSV 2018 年 1 月 1 日

1 投票

This line is not correct:
output_E(t)_it(t,r,it)=output_E(t,r);
You should change it to:
output_Et_it(t,r,it)=output_E(t,r);

4 件のコメント

Prabha Kumaresan
Prabha Kumaresan 2018 年 1 月 1 日
編集済み: Walter Roberson 2018 年 1 月 1 日
After changing into
output_Et_it(t,r,it)=output_E(t,r);
I am getting
Undefined function 'sum' for input arguments of type
'function_handle'.
Error in (line 13)
overall_throughput_Et = sum(sum(throughput_Et));
Walter Roberson
Walter Roberson 2018 年 1 月 1 日
It is not clear why you changed that code from your previous
overall_throughput_E(t) = sum(sum(throughput_E(t)));
Function handles can be:
1) Assigned to a variable, as in
MyFun = @(t) exp(-t) - sin(t);
SecondVariable = MyFun;
2) Passed to another function, as in
MyFun = @(t) exp(-t) - sin(t);
fzeros(MyFun, 5)
3) Invoked, as in
sum(MyFun(0:.1:5))
Any other use is not valid. You cannot sum() a function handle, for example: you have to sum() the result of invoking the function handle.
Prabha Kumaresan
Prabha Kumaresan 2018 年 1 月 2 日
編集済み: Walter Roberson 2018 年 1 月 2 日
The reason i have changed the code is due to the throughput expression which was given below.
If i run the code i am getting the error as stated before.
throughput_Et = @(t)Bmax * log2(1 + p_fix(t)*gamma(t)/sum(p_fix(1:t-1).* gamma(t)));
overall_throughput_Et = sum(sum(throughput_Et));
output_E(t,r)=overall_throughput_Et;
output_Et_it(t,r,it)=output_E(t,r);
Walter Roberson
Walter Roberson 2018 年 1 月 2 日
You define
p_fix=0.01; %fixed transmit power is assumed
which makes p_fix a scalar. But you are using p_fix(t) and p_fix(1:t-1) which assume that t is either empty or is exactly 1 or is true or false (otherwise you would be indexing outside the array.)
You are looping over it and t and r but your calculations do not use it or r so taking a 2D sum does not make any sense.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 1 月 1 日

0 投票

Your code line is
output_E(t)_it(t,r,it)=output_E(t,r);
Underscore is not a valid character immediately after the (t)

カテゴリ

ヘルプ センター および File ExchangeAerospace Blockset についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by