No BSD License  

Highlights from
BPSK Simulator for Low Rate Transmisions

image thumbnail
from BPSK Simulator for Low Rate Transmisions by César Delgado González
BPSK Simulator for didactical purposes. Systemic coding style.

guardar(ruta,file,datos,tipo,primera)
function  [ok] = guardar(ruta,file,datos,tipo,primera)

%------------------------------------------------------------------------
%|  function  [ok] = guardar(ruta,file,datos,tipo,primera)
%------------------------------------------------------------------------
%|    Funcin que escribe un fichero.
%|
%|    Entradas:
%|       1.- RUTA      : dnde est fichero con los cdigos (Fila caracteres)
%|       2.- FILE      : nombre del fichero con los cdigos (Fila caracteres)
%|       3.- TIPO      : tipo de fichero a leer:
%|                0 = INFO: secuencia de "0" y "1" con la informacin a TX.
%|                1 = TRAMA:  fichero de tramas, organizado matricialmente.
%|                2 = SEAL:  fichero con la seal del algn punto de observ.
%|       4.- PRIMERA   : bandera: 
%|                       1 = 1 apertura del fichero
%|                       0 = N-sima apertura del fichero
%|                       Valor por defecto: 1;
%|
%|    Salida:
%|       1.- OK   = es el identificador del fichero. Sirve para saber si
%|                   la escritura se ha realizado correctamente.
%-------------------------------------------------------------------------
%|   Autor: Cesar Delgado
%|   Fecha: 19-Abril-2.004
%-------------------------------------------------------------------------

ok = -1;
if nargin<4, disp('ERROR: Parmetros insuficientes en guardar');    
else   
   if nargin < 5, primera=1; end;
         
 %%%%%%%%%%%%%%%%%%%%%% FICHEROS DE SEALES %%%%%%%%%%%%%%%%%%%%%%
   if tipo > 1, 
      if primera, % Borramos datos exitentes
         Fic=fopen([ruta file],'wb'); 
         fwrite(Fic,[],'float64');
         fclose(Fic);
         Fic=fopen([ruta file],'wb');
      else
         Fic=fopen([ruta file],'ab');         
      end;      
      
      fwrite(Fic,datos,'float64');
      ok = Fic;
      fclose(Fic);              
      
      
 %%%%%%%%%%%%%%%%%%%%%%%%% FICHERO BINARIOS %%%%%%%%%%%%%%%%%%%%%%
   else       
      if primera, % Borramos datos existentes
         Fic=fopen([ruta file],'wb'); 
         fwrite(Fic,[],'uint8');
         fclose(Fic);
         Fic=fopen([ruta file],'wb');
      else
         Fic=fopen([ruta file],'ab');
      end;
      Fic=fopen([ruta file],'ab');
      fwrite(Fic,datos,'uint8');
      ok = Fic;
      fclose(Fic);              
      
   end;    % del if tipo
end;       % del if nargin

   

Contact us at files@mathworks.com