Using global variables in EMLMEX
Show older comments
Hi all, I have a doubt about how to use global variables in EMLMEX. I tried sending them as parameter but it didn't worked. Code: 1function [final_full_list_1 est_sym_1 metric_1] = list_decode(z,SYM_x3_search,binary_table_x3,Nbpsc,kmod,R_loc,mod_type1,mod_type2,mod_type3,const1,const2,const3,order,fxp,ml) 2 3% if osic_option == 6 (ML), then we do 256x6 for 256 qam 3SS, 64x6 for 64 qam 4% 3SS, 3*16^2 for 16 qam 3SS, 3*4^2 for qpsk 3SS, 3*2^2 for bpsk 3SS 5% for 2SS, full list 256x2 or 64x2 is ML 6 7global SYM; global binary_table; global const; global conste_bits; global const_bits; 8global fp_llr; global fp_rsym_prod; global fp_zrsym_sum; global fp_dist; 9global fp_x_dmp; 10%------------------------- 11global demapper_ones_enable; 12global norm_comp_ones_enable; 13global norm_approx_enable; 14global do_llr_quantization; 15global llr_out_format; 16%------------------------- 17[nr nt] = size(R_loc); 18dmp_fmt = fp_x_dmp.format; 19resolution = (0.5)^(fp_x_dmp.format(2)); 20 21if(nr == 3) 22 R_23_loc_in_cnc = R_loc(2,3); 23 R_13_loc_in_cnc = R_loc(1,3); 24end 25R_12_loc_in_cnc = R_loc(1,2); 26 27if((ml == 1) && ((Nbpsc(1) == 1) (Nbpsc(1) == 2) (Nbpsc(1) == 4)) && (nr == 3)) 28 SYM_x2_tot = reshape(repmat(SYM_x3_search.',1,2^Nbpsc(2)),1,[])*kmod(2); % x1 to x16 followed by x1 to x16 and so on 29 SYM_x3_tot = reshape(repmat(SYM_x3_search,2^Nbpsc(3),1),[],1).'*kmod(3); % x1 16 times followed by x2 16 times and so on 30 SYM_x2_tot = SYM_x2_tot.'; 31 SYM_x3_tot = SYM_x3_tot.'; 32 binary_table_x2_tot = repmat(binary_table_x3,2^Nbpsc(2),1); 33 binary_table_x3_tot = reshape(repmat(binary_table_x3',2^Nbpsc(3),1),Nbpsc(3),[])'; 34end 35 36% Estimate X2 37if(nr == 3) 38 SYM_loc = SYM_x3_search.'*kmod(3);% local symbol definition 39 rsym_prod = our_quantizer(R_23_loc_in_cnc*(SYM_loc),fp_rsym_prod.format(1)-fp_rsym_prod.format(2)-1,fp_rsym_prod.format(2),fxp);% 1 3 12 format 40 x2_est = our_quantizer(z(2) -rsym_prod,fp_zrsym_sum.format(1)-fp_zrsym_sum.format(2)-1,fp_zrsym_sum.format(2),fxp); 41else 42 SYM_loc = SYM_x3_search.'*kmod(2);% local symbol definition 43 rsym_prod = our_quantizer(R_12_loc_in_cnc*(SYM_loc),fp_rsym_prod.format(1)-fp_rsym_prod.format(2)-1,fp_rsym_prod.format(2),fxp);% 1 3 12 format 44 x2_est = our_quantizer(z(1) -rsym_prod,fp_zrsym_sum.format(1)-fp_zrsym_sum.format(2)-1,fp_zrsym_sum.format(2),fxp); 45end 46 47fp_x2_est = quantizer([16 12]); 48if(nr == 3) 49 if((ml == 1) && ((Nbpsc(1) == 1) (Nbpsc(1) == 2) (Nbpsc(1) == 4)) && (nr == 3)) 50 x2_est_bits = binary_table_x2_tot; 51 else 52 x2_est_bits = double([hard_demapper(mod_type2,real(x2_est),our_quantizer(2*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable) hard_demapper(mod_type2,imag(x2_est),our_quantizer(2*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(2,2),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable)]); 53 end 54else 55 x2_est_bits = double([hard_demapper(mod_type1,real(x2_est),our_quantizer(2*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable) hard_demapper(mod_type1,imag(x2_est),our_quantizer(2*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable)]); 56end 57 58if(nr == 3) 59 Nbpsc_tmp = Nbpsc(2); const_tmp = const2; kmod_tmp = kmod(2); 60else 61 Nbpsc_tmp = Nbpsc(1); const_tmp = const1; kmod_tmp = kmod(1); 62end 63if (Nbpsc_tmp ~= 1) 64 x2_est_bits = x2_est_bits; 65 x2_est_sym = (const_tmp(bi2de(fliplr(x2_est_bits(:,1:Nbpsc_tmp/2 )))+1) + j*const_tmp(bi2de(fliplr(x2_est_bits(:,Nbpsc_tmp/2+1:Nbpsc_tmp)))+1)) * kmod_tmp; 66 x2_est_sym = x2_est_sym.'; 67else 68 x2_est_bits = x2_est_bits(:,1); 69 x2_est_sym = const_tmp(x2_est_bits + 1); 70 x2_est_sym = x2_est_sym.'; 71end 72 73if(nr == 2) 74 x1_est = x2_est; 75 x1_est_sym = x2_est_sym; 76 x1_est_bits = x2_est_bits; 77end 78 79if(nr == 3) 80 % Estimate X1 81 SYM_loc = SYM_x3_search.'*kmod(3);% local symbol definition 82 if((ml == 1) && ((Nbpsc(1) == 1) (Nbpsc(1) == 2) (Nbpsc(1) == 4)) && (nr == 3)) 83 rsym_prod = our_quantizer(R_12_loc_in_cnc*(SYM_x2_tot)+R_13_loc_in_cnc*(SYM_x3_tot),fp_rsym_prod.format(1)-fp_rsym_prod.format(2)-1,fp_rsym_prod.format(2),fxp);% 1 3 12 format 84 else 85 rsym_prod = our_quantizer(R_12_loc_in_cnc*(x2_est_sym)+R_13_loc_in_cnc*(SYM_loc),fp_rsym_prod.format(1)-fp_rsym_prod.format(2)-1,fp_rsym_prod.format(2),fxp);% 1 3 12 format 86 end 87 x1_est = our_quantizer(z(1) -rsym_prod,fp_zrsym_sum.format(1)-fp_zrsym_sum.format(2)-1,fp_zrsym_sum.format(2),fxp); 88 89 fp_x1_est = quantizer([16 12]); 90 x1_est_bits = double([hard_demapper(mod_type1,real(x1_est),our_quantizer(2*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable) hard_demapper(mod_type1,imag(x1_est),our_quantizer(2*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(4*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),our_quantizer(8*R_loc(1,1),dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2),fxp),resolution,demapper_ones_enable)]); 91 92 if (Nbpsc(1) ~= 1) 93 x1_est_bits = x1_est_bits; 94 x1_est_sym = (const1(bi2de(fliplr(x1_est_bits(:,1:Nbpsc(1)/2 )))+1) + j*const1(bi2de(fliplr(x1_est_bits(:,Nbpsc(1)/2+1:Nbpsc(1))))+1)) * kmod(1); 95 x1_est_sym = x1_est_sym.'; 96 else 97 x1_est_bits = x1_est_bits(:,1); 98 x1_est_sym = const1(x1_est_bits(:,1) + 1); 99 x1_est_sym = x1_est_sym.'; 100 end 101end 102 103d1 = x1_est - our_quantizer(R_loc(1,1)*x1_est_sym,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); %dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2)); 104if(nr == 3) 105 if((ml == 1) && ((Nbpsc(1) == 1) (Nbpsc(1) == 2) (Nbpsc(1) == 4)) && (nr == 3)) 106 d2 = z(2) - our_quantizer(R_loc(2,2)*SYM_x2_tot+R_loc(2,3)*SYM_x3_tot,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); %dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2)); 107 d3 = z(3) - our_quantizer(R_loc(3,3)*SYM_x3_tot,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); 108 else 109 d2 = z(2) - our_quantizer(R_loc(2,2)*x2_est_sym+R_loc(2,3)*SYM_loc,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); %dmp_fmt(1)-dmp_fmt(2)-1,dmp_fmt(2)); 110 d3 = z(3) - our_quantizer(R_loc(3,3)*SYM_loc,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); 111 end 112 dist_1 = [d1.';d2.';d3.']; 113else 114 d2 = z(2) - our_quantizer(R_loc(2,2)*SYM_loc,fp_dist.format(1)-fp_dist.format(2)-1,fp_dist.format(2),fxp); 115 dist_1 = [d1.';d2.']; 116end 117 118if((ml == 1) && ((Nbpsc(1) == 1) (Nbpsc(1) == 2) (Nbpsc(1) == 4)) && (nr == 3)) 119 x2_est_bits = binary_table_x2_tot; 120 binary_table_x3 = binary_table_x3_tot; 121 x2_est_sym = SYM_x2_tot; 122 SYM_x3_search = SYM_x3_tot.'/kmod(3); 123end 124 125if(nr == 3) 126 if(sum(order == [1 2 3]) == 3) 127 final_full_list_1 = [x1_est_bits x2_est_bits binary_table_x3]; 128 est_sym_1 = [ x1_est_sym x2_est_sym SYM_x3_search.'*kmod(3) ]; 129 elseif(sum(order == [2 3 1]) == 3) 130 final_full_list_1 = [binary_table_x3 x1_est_bits x2_est_bits]; 131 est_sym_1 = [ SYM_x3_search.'*kmod(3) x1_est_sym x2_est_sym ]; 132 elseif(sum(order == [3 1 2]) == 3) 133 final_full_list_1 = [x2_est_bits binary_table_x3 x1_est_bits]; 134 est_sym_1 = [ x2_est_sym SYM_x3_search.'*kmod(3) x1_est_sym ]; 135 elseif(sum(order == [1 3 2]) == 3) 136 final_full_list_1 = [x1_est_bits binary_table_x3 x2_est_bits]; 137 est_sym_1 = [ x1_est_sym SYM_x3_search.'*kmod(3) x2_est_sym ]; 138 elseif(sum(order == [2 1 3]) == 3) 139 final_full_list_1 = [x2_est_bits x1_est_bits binary_table_x3]; 140 est_sym_1 = [ x2_est_sym x1_est_sym SYM_x3_search.'*kmod(3) ]; 141 elseif(sum(order == [3 2 1]) == 3) 142 final_full_list_1 = [binary_table_x3 x2_est_bits x1_est_bits]; 143 est_sym_1 = [ SYM_x3_search.'*kmod(3) x2_est_sym x1_est_sym ]; 144 end 145% switch order(1) 146% case 1, 147% final_full_list_1_1 = x1_est_bits; est_sym_1_1 = x1_est_sym; 148% case 2, 149% final_full_list_1_1 = binary_table_x3; est_sym_1_1 = SYM_x3_search.'*kmod1; 150% case 3, 151% final_full_list_1_1 = x2_est_bits; est_sym_1_1 = x2_est_sym; 152% otherwise, 153% disp('error in list_decode'); 154% end 155% switch order(2) 156% case 1, 157% final_full_list_1_2 = binary_table_x3; est_sym_1_2 = SYM_x3_search.'*kmod1; 158% case 2, 159% final_full_list_1_2 = x2_est_bits; est_sym_1_2 = x2_est_sym; 160% case 3, 161% final_full_list_1_2 = x1_est_bits; est_sym_1_2 = x1_est_sym; 162% otherwise, 163% disp('error in list_decode'); 164% end 165% switch order(3) 166% case 1, 167% final_full_list_1_3 = x2_est_bits; est_sym_1_3 = x2_est_sym; 168% case 2, 169% final_full_list_1_3 = x1_est_bits; est_sym_1_3 = x1_est_sym; 170% case 3, 171% final_full_list_1_3 = binary_table_x3; est_sym_1_3 = SYM_x3_search.'*kmod1; 172% otherwise, 173% disp('error in list_decode'); 174% end 175% final_full_list_1 = [ final_full_list_1_1 final_full_list_1_2 final_full_list_1_3 ]; 176% est_sym_1 = [ est_sym_1_1 est_sym_1_2 est_sym_1_3 ]; 177 metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 178else 179 switch order(1) 180 case 1, 181 final_full_list_1_1 = x1_est_bits; est_sym_1_1 = x1_est_sym; 182 case 2, 183 final_full_list_1_1 = binary_table_x3; est_sym_1_1 = SYM_x3_search.'*kmod(2); 184 otherwise, 185 disp('error in list_decode'); 186 end 187 switch order(2) 188 case 1, 189 final_full_list_1_2 = x1_est_bits; est_sym_1_2 = x1_est_sym; 190 case 2, 191 final_full_list_1_2 = binary_table_x3; est_sym_1_2 = SYM_x3_search.'*kmod(2); 192 otherwise, 193 disp('error in list_decode'); 194 end 195 final_full_list_1 = [ final_full_list_1_1 final_full_list_1_2 ]; 196 est_sym_1 = [ est_sym_1_1 est_sym_1_2 ]; 197 metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 198end 199 200 201% if(nr == 3) 202% if(sum(order == [1 2 3]) == 3) 203% final_full_list_1 = [x1_est_bits x2_est_bits binary_table_x3]; 204% est_sym_1 = [ x1_est_sym x2_est_sym SYM_x3_search.'*kmod1 ]; 205% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 206% elseif(sum(order == [2 3 1]) == 3) 207% final_full_list_1 = [binary_table_x3 x1_est_bits x2_est_bits]; 208% est_sym_1 = [ SYM_x3_search.'*kmod1 x1_est_sym x2_est_sym ]; 209% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 210% elseif(sum(order == [3 1 2]) == 3) 211% final_full_list_1 = [x2_est_bits binary_table_x3 x1_est_bits]; 212% est_sym_1 = [ x2_est_sym SYM_x3_search.'*kmod1 x1_est_sym ]; 213% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 214% elseif(sum(order == [3 2 1]) == 3) 215% final_full_list_1 = [binary_table_x3 x2_est_bits x1_est_bits]; 216% est_sym_1 = [ SYM_x3_search.'*kmod1 x2_est_sym x1_est_sym ]; 217% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 218% end 219% else 220% if(sum(order == [1 2]) == 2) 221% final_full_list_1 = [x1_est_bits binary_table_x3]; 222% est_sym_1 = [ x1_est_sym SYM_x3_search.'*kmod1 ]; 223% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 224% else 225% final_full_list_1 = [binary_table_x3 x1_est_bits]; 226% est_sym_1 = [SYM_x3_search.'*kmod1 x1_est_sym]; 227% metric_1 = norm_compute_fix_model(dist_1,norm_comp_ones_enable,norm_approx_enable,fxp); 228% end 229% end 230
Errors: Type Location Message Warning list_decode.m:7:1 Unsupported: GLOBAL variables. Warning list_decode.m:7:13 Unsupported: GLOBAL variables. Warning list_decode.m:7:34 Unsupported: GLOBAL variables. Warning list_decode.m:7:48 Unsupported: GLOBAL variables. Warning list_decode.m:7:68 Unsupported: GLOBAL variables. Warning list_decode.m:8:1 Unsupported: GLOBAL variables. Warning list_decode.m:8:16 Unsupported: GLOBAL variables. Warning list_decode.m:8:37 Unsupported: GLOBAL variables. Warning list_decode.m:8:58 Unsupported: GLOBAL variables. Warning list_decode.m:9:1 Unsupported: GLOBAL variables. Warning list_decode.m:11:1 Unsupported: GLOBAL variables. Warning list_decode.m:12:1 Unsupported: GLOBAL variables. Warning list_decode.m:13:1 Unsupported: GLOBAL variables. Warning list_decode.m:14:1 Unsupported: GLOBAL variables. Warning list_decode.m:15:1 Unsupported: GLOBAL variables. Error list_decode.m:18:11 Unsupported: GLOBAL variables. Error list_decode.m:19:21 Unsupported: GLOBAL variables. Error list_decode.m:28:26 Size arguments must be constants. Error list_decode.m:29:26 Size arguments must be constants. Error list_decode.m:30:18 Undefined function or variable 'SYM_x2_tot'. The first assignment to a local variable determines its class. Error list_decode.m:31:18 Undefined function or variable 'SYM_x3_tot'. The first assignment to a local variable determines its class. Error list_decode.m:32:27 Size arguments must be constants. Error list_decode.m:33:35 Size arguments must be constants. Error list_decode.m:39:57 Unsupported: GLOBAL variables. Error list_decode.m:40:34 Undefined function or variable 'rsym_prod'. The first assignment to a local variable determines its class. Error list_decode.m:47:13 Function 'quantizer' resolved in the MATLAB workspace. Implicit evaluation in MATLAB is not supported. Please declare this function extrinsic using eml.extrinsic('quantizer'), or call it using feval. Error list_decode.m:50:23 Undefined function or variable 'binary_table_x2_tot'. The first assignment to a local variable determines its class. Error list_decode.m:52:60 Undefined function or variable 'x2_est'. The first assignment to a local variable determines its class. Error list_decode.m:64:19 Undefined function or variable 'x2_est_bits'. The first assignment to a local variable determines its class. Error list_decode.m:65:42 Undefined function or variable 'x2_est_bits'. The first assignment to a local variable determines its class. Error list_decode.m:66:18 Undefined function or variable 'x2_est_sym'. The first assignment to a local variable determines its class. Error list_decode.m:68:19 Undefined function or variable 'x2_est_bits'. The first assignment to a local variable determines its class. Error list_decode.m:69:28 Undefined function or variable 'x2_est_bits'. The first assignment to a local variable determines its class. Error list_decode.m:70:18 Undefined function or variable 'x2_est_sym'. The first assignment to a local variable determines its class. Error list_decode.m:83:52 Undefined function or variable 'SYM_x2_tot'. The first assignment to a local variable determines its class. Error list_decode.m:83:52 Error limit reached. Suppressing further error messages.
1 Comment
Walter Roberson
on 3 Oct 2012
Please format the question; see http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Please read the Guide to Tags and retag this question; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
Answers (0)
Categories
Find more on QAM 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!