greater than less than
조회 수: 3 (최근 30일)
이전 댓글 표시
- 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
댓글 수: 0
답변 (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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!