greater than less than
이전 댓글 표시
- close all;
- tag_arr = randi(0:1,1,8);
- N = 16;
- hadamardmat = hadamard(N);
- codeTx1 = hadamardmat(:,1);
- codeTx2 = hadamardmat(:,2);
- codeTx3 = hadamardmat(:,3);
- codeTx4 = hadamardmat(:,4);
- codeTx5 = hadamardmat(:,5);
- codeTx6 = hadamardmat(:,6);
- codeTx7 = hadamardmat(:,7);
- codeTx8 = hadamardmat(:,8);
- code_Tx9 = hadamardmat(:,9);
- code_Tx10 = hadamardmat(:,10);
- code_Tx11 = hadamardmat(:,11);
- code_Tx12 = hadamardmat(:,12);
- code_Tx13 = hadamardmat(:,13);
- code_Tx14 = hadamardmat(:,14);
- code_Tx15 = hadamardmat(:,15);
- code_Tx16 = hadamardmat(:,16);
- scm = [codeTx1 codeTx2 codeTx3 codeTx4 codeTx5 codeTx6 codeTx7 codeTx8 code_Tx9 code_Tx10 code_Tx11 code_Tx12 code_Tx13 code_Tx14 code_Tx15 code_Tx16];
- sc_t = scm;
- sc_t(sc_t == -1) = 0;
- sc_o=sc_t;
- no_oftags = 5;
- out_array = zeros(no_oftags,16);
- for n = 1:no_oftags
- out_array(n,:) = xor(tag_arr(1,n),sc_t(n,:));
- end
- tau = zeros(1,no_oftags);
- sigma = 1;
- for n = 1:no_oftags
- tau(1,n) = sigma*sqrt(-2*log(1-rand(1)));
- end
- volts_forall = zeros(no_oftags,16);
- for n = 1:no_oftags
- volts_forall(n,:) = ((-5 + 10*(out_array(n,:)*tau(1,n))));
- end
- volts_add = zeros(1,16);
- for n = 1:no_oftags
- volts_add(1,:) = volts_add + (volts_forall(n,:));
- end
- voltsadd_val = volts_add;
- voltsadd_val(voltsadd_val>=0) = 1;
- voltsadd_val(voltsadd_val<0) = 0;
I am trying a code where I have to simple make all the positive values to 1 and negative values to 0 in voltsadd_val matrix but whenever i run the program the syntax doesnt work prroperly. I dont know whats wrong ..
eg
volts_add =
Columns 1 through 11
10.2478 11.0875 8.3853 -11.0500 14.2229 15.0626 12.3604 -7.0749 10.2478 11.0875 8.3853
Columns 12 through 16
-11.0500 14.2229 15.0626 12.3604 -7.0749
voltsadd_val =
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
답변 (2개)
Kevin Phung
2019년 2월 15일
here's an example:
voltsadd_val = [1 5 3; -2 -5 5; 1 -5 3];
voltsadd_val(voltsadd_val>0) = 1; % if pos, 1
voltsadd_val(voltsadd_val<0) = 0; % if neg, 0
댓글 수: 2
madhan ravi
2019년 2월 16일
Suspect the OP did the same thing not sure why the OP says it doesn’t work though. Maybe more expanation is needed then.
Ayesha Punjabi
2019년 2월 18일
Walter Roberson
2019년 2월 18일
voltsadd_val = volts_add >= 0;
No logical indexing required.
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
