MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

0

How do i create lots of gaussian channel?

yang-En Hsiao さんによって質問されました 2019 年 2 月 9 日
最新アクティビティ Rik
さんによって コメントされました 2019 年 2 月 18 日
How to build K gaussian channel code in matlab ? i mean if $h_1,h_2,...,h_K$ are all gaussian channel,how do i write this code in just one or two line code?I know how to write the code if there is just one gaussian channel
`h=sqrt(1/2)*(randn(1,size(x))+1i*randn(1,size(x)));`
But i think it is stupid to write as
h_1=sqrt(1/2)*(randn(1,size(x))+1i*randn(1,size(x)))
h_2=sqrt(1/2)*(randn(1,size(x))+1i*randn(1,size(x)))...
h_K=sqrt(1/2)*(randn(1,size(x))+1i*randn(1,size(x)))
then h=[h_1 h_2 h_3 ...h_k]
Does anyone know the better (smarter ) way to write this code?

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

回答者: Rik
2019 年 2 月 9 日

There are many ways to do something like this. You can either fill your array by using cellfun, or a loop, or a direct calculation.
Your input to the randn function seems a bit strange, as you can't mix the scalar input type with the vector input type.
%assuming you meant randn([1 size(x)]) and h=[h_1;h_2;h_K]
h=sqrt(1/2)*(randn([K,size(x)])+1i*randn([K,size(x)]));
%otherwise:
h_k=@(k) sqrt(1/2)*(randn([1,size(x)])+1i*randn([1,size(x)]));%adapt to your needs
h=1:K;%reshape to whatever shape you need
h=cellfun(h_k,num2cell(h));

  1 件のコメント

Rik
2019 年 2 月 18 日
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

サインイン to comment.



Translated by