To concatenate rows in matrix within for loop based on if else statement
5 ビュー (過去 30 日間)
om prakash 2019 年 9 月 24 日
回答済み: om prakash 2019 年 10 月 3 日
m = 2;
PU = 4;
PU = input('Enter No. of primary user = ');
Fc = zeros(1, PU);
if PU >=1
for x = 1:PU
Fc(x) = input('Enter 1 for signal present and 0 for noise in channel = ');
disp('No primary signal detected');
table = zeros(m,PU*NumBits);
for index = 1:(PU)
if Fc(index) == 1
table = [temp(ii,:) temp_noise(ii,:)]
can somebody tell me how to do this. I have to store values in rows.
I have edited the code for better understanding. Hope it helps.
If PU is 4 with values 1011, then values generated due to these values should be stored in concatenation to evaluate further.
回答 (2 件)
Jos (10584) 2019 年 9 月 24 日
This code is weird.
In each iteration of "index" you fill either a matrix temp or a matrix temp_noise with m rows of values.
Then you concatenate only the last (= ii-th) row of both of these matrices into a single row, and store this in the variable table. One the of these last rows was just created, and for the other one you use the one created one or more iterations ago.
At every subsequention iteration, this variable table is overwritten.
So, first you need to carefully think about what you are trying to do ....
Find more on Matrix Indexing 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!