/*============================================================================
* Syntax: [sys, x0, str, ts] =
* sviterbi(t,x,u,flag,tran_func,leng,tran_prob,plot_flag,V1,V2,V3,V4);
*SVITERBI SIMULINK file for convolution decoding using viterbi algorithm.
* This file is designed to be used in a SIMULINK S-Function block.
* The function requires the system inputs
* code_param = [N, K, M, num_state, num_std_sta]; % prepared by simviter
* tran_func = [A, B; C, D]; % prepared by simviter
* leng % memory length
* tran_prob % transfer probability
* % when it is not a three row matrix, take the code as hard decision one.
* plot_flag % should plot or not.
* % when it is not a positive integer, don't plot.
* % when it is a positive integer, keep the plot have the time length
* % as required.
* This function keeps a number of discrete-time states:
* figure number. -Inf: to be opened; 0 not need to plot; positive: handle
* figure posit. Current figure position.
* trace_num. current trace number.
* trace_flag. flag to indicate that computation is not under leng.
* stater. variable in keeping the very beinging of state.
* trace. a LENG-by-NUM_STD_STA matrix storage the traces.
* solut. a LENG-by-NUM_STD_STA matrix storage the possible msg.
* expense. a 2-by-NUM_STD_STA matrix storage the expense.
*
* P.S. The most of comments are written in Matlab file.
*=============================================================================
* Original designed by Wes Wang,
* Jun Wu, The Mathworks, Inc.
* Feb-07, 1996
*
* Copyright (c) 1996 by The MAthWorks, Inc.
* All Rights Reserved
* $Revision: 1.1 $ $Date: 1996/04/01 19:06:23 $
*=============================================================================
*/
#define S_FUNCTION_NAME sviterbi
/* M-files sviplot1.m sviplot2.m sviplot3.m and sviplot4.m
* are needed if you want plot the figures.
*/
#ifdef MATLAB_MEX_FILE
#include "mex.h"
#endif
#include <math.h>
/* need to include simstruc.h for the definition of the SimStruct and
* its associated macro definitions.
*/
#include "simstruc.h"
#define NUM_ARGS 8 /* eight additional input arguments */
#define TRAN_FUNC ssGetArg(S,0) /* the length of output vector */
#define LENG ssGetArg(S,1) /* the memory length */
#define TRAN_PROB ssGetArg(S,2) /* the transfer probability */
#define PLOT_FLAG ssGetArg(S,3) /* the flag of plot */
#define V1 ssGetArg(S,4)
#define V2 ssGetArg(S,5)
#define V3 ssGetArg(S,6)
#define V4 ssGetArg(S,7)
#define Prim 2
void de2bi(pde, dim, pow_dim, pbi)
int *pde, dim, pow_dim, *pbi;
{
int i,j, tmp;
if( pde[0] < 0 ){
/* the first part is for converting the decimal numbers(from 0 to pow_dim)
* to binary.
*/
for(i=0; i < pow_dim; i++){
tmp = i;
for(j=0; j < dim; j++){
pbi[i+j*pow_dim] = tmp % Prim;
if(j < dim-1)
tmp = (int)(tmp/Prim);
}
}
}else{
/* the second part is for converting the decimal numbers(setting by user)
* to binary.
*/
for(i=0; i < pow_dim; i++){
tmp = pde[i];
for(j=0; j < dim; j++){
pbi[i+j*pow_dim] = tmp % Prim;
if(j < dim-1)
tmp = (int)(tmp/Prim);
}
}
}
}
static void bi2de(pbi, pow_dim, dim, pde)
int *pbi, pow_dim, dim, *pde;
{
int i, j, k;
for(i=0; i<pow_dim; i++)
pde[i] = 0;
for (i=0; i < pow_dim; i++){
for (j=0; j < dim; j++){
if (pbi[i+j*pow_dim] != 0){
if(j > 0){
for (k=0; k < j; k++)
pbi[i+j*pow_dim] = pbi[i+j*pow_dim]*Prim;
}
}
pde[i] = pde[i] + (int)pbi[i+j*pow_dim];
}
}
}
/*
* See also vitshort.c and vitshort.m for the two functions following.
*/
static void shortdbl(expense, sol, n_std_sta, Rwork, Iwork)
double *expense, *sol, *Rwork;
int *Iwork, n_std_sta;
{
int i, j, k, PowPowM, aft_indx, len_indx, len, indx;
int *wei_indx, *sub_indx;
double max;
double *wei_mat_exp, *wei_sum, *sol_tmp;
double wei_mat_sol;
wei_mat_exp = Rwork;
wei_sum = Rwork + n_std_sta;
sol_tmp = Rwork + 2*n_std_sta;
wei_indx = Iwork;
sub_indx = Iwork + n_std_sta;
PowPowM = n_std_sta * n_std_sta;
for(i=0; i < PowPowM; i++)
sol_tmp[i] = sol[i];
for(i=1; i <= n_std_sta; i++){
aft_indx = i * n_std_sta - n_std_sta;
for(j=1; j <= n_std_sta; j++){
for(k=0; k < n_std_sta; k++)
wei_mat_exp[k] = expense[k * n_std_sta + j - 1];
len_indx = 0;
for(k=0; k < n_std_sta; k++){
wei_mat_sol = sol_tmp[aft_indx + k];
if ( wei_mat_exp[k] > 0 || wei_mat_sol > 0 ) {
wei_sum[k] = 1;
}else{
wei_sum[k] = wei_mat_exp[k] + wei_mat_sol;
wei_indx[len_indx] = k;
len_indx++;
}
}
if (len_indx > 0) {
len = 0;
max = wei_sum[wei_indx[0]];
sub_indx[0] = wei_indx[0];
k = 1;
while (k < len_indx) {
if ( max < wei_sum[wei_indx[k]] ) {
max = wei_sum[wei_indx[k]];
sub_indx[0] = wei_indx[k];
}
k++;
}
for(k=0; k < len_indx; k++){
if (wei_sum[wei_indx[k]] == max ){
sub_indx[len] = wei_indx[k];
len++;
}
}
indx = sub_indx[0];
if (len > 1){
max = wei_mat_exp[sub_indx[0]];
k = 1;
while(k < len){
if( max < wei_mat_exp[sub_indx[k]] ) {
max = wei_mat_exp[sub_indx[k]];
indx = sub_indx[k];
}
k++;
}
}
sol[aft_indx + j - 1] = wei_sum[indx];
}else{
sol[aft_indx + j - 1] = 1;
}
}
}
}
static void shortint(expense, sol, n_std_sta, Iwork)
int *expense, *sol, *Iwork;
int n_std_sta;
{
int i, j, k, PowPowM, aft_indx, len_indx, len, indx;
int min;
int wei_mat_sol;
int *wei_mat_exp, *wei_sum, *sol_tmp, *wei_indx, *sub_indx;
wei_mat_exp = Iwork;
wei_sum = Iwork + n_std_sta;
wei_indx = Iwork + 2*n_std_sta;
sub_indx = Iwork + 3*n_std_sta;
sol_tmp = Iwork + 4*n_std_sta;
PowPowM = n_std_sta * n_std_sta;
for(i=0; i < PowPowM; i++)
sol_tmp[i] = sol[i];
for(i=1; i <= n_std_sta; i++){
aft_indx = i * n_std_sta - n_std_sta;
for(j=1; j <= n_std_sta; j++){
for(k=0; k < n_std_sta; k++)
wei_mat_exp[k] =expense[k * n_std_sta + j - 1];
len_indx = 0;
for(k=0; k < n_std_sta; k++){
wei_mat_sol = sol_tmp[aft_indx + k];
if ( wei_mat_exp[k] < 0 || wei_mat_sol < 0 ) {
wei_sum[k] = -1;
}else{
wei_sum[k] = wei_mat_exp[k] + wei_mat_sol;
wei_indx[len_indx] = k;
len_indx++;
}
}
if (len_indx > 0) {
len = 0;
min = wei_sum[wei_indx[0]];
sub_indx[0] = wei_indx[0];
k = 1;
while (k < len_indx) {
if ( min > wei_sum[wei_indx[k]] ) {
min = wei_sum[wei_indx[k]];
sub_indx[0] = wei_indx[k];
}
k++;
}
for(k=0; k < len_indx; k++){
if (wei_sum[wei_indx[k]] == min ){
sub_indx[len] = wei_indx[k];
len++;
}
}
indx = sub_indx[0];
if (len > 1){
min = wei_mat_exp[sub_indx
没有合适的资源?快使用搜索试试~ 我知道了~
例程:通信系统与 MATLAB (Proakis)
共1087个文件
m:917个
mex:62个
c:57个
5星 · 超过95%的资源 需积分: 10 40 下载量 75 浏览量
2008-04-13
11:33:52
上传
评论
收藏 2.61MB RAR 举报
温馨提示
例程:通信系统与 MATLAB (Proakis)
资源推荐
资源详情
资源评论
收起资源包目录
例程:通信系统与 MATLAB (Proakis) (1087个子文件)
SVITERBI.C 59KB
GFLIB.C 58KB
GFLIB.C 58KB
SVITERBA.C 48KB
VITCORE.C 36KB
V34TRANS.C 15KB
SREADFIL.C 14KB
APSKDEM3.C 13KB
APSKDEMO.C 12KB
V34RECV.C 12KB
APSKDEM2.C 12KB
SCONVENC.C 12KB
CMPLXFLT.C 11KB
REGDOWN.C 11KB
SIMRSCBV.C 11KB
SWRIWKS.C 10KB
SWRITWKS.C 10KB
MOVEINT.C 9KB
SIMRSDBV.C 9KB
REGSHIFT.C 9KB
STDMAMUX.C 9KB
HOMOPULS.C 9KB
SWRITFIL.C 9KB
SRANDBIT.C 9KB
SIMRSCOD.C 8KB
SCHDINT.C 8KB
SIMRSDEC.C 8KB
SIMBCHDC.C 7KB
SRANDINT.C 7KB
VITSHORT.C 6KB
SURANDOM.C 6KB
ARYSIN.C 6KB
GFADD.C 6KB
VITSHORT.C 6KB
SUNBUFF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ab程序。
morre
- 粉丝: 187
- 资源: 2337
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功