Не могу сделать amdemod в OCTAVE - PullRequest
0 голосов
/ 02 апреля 2020

Я нашел следующий код для эксперимента AM mod и demod. Однако я не могу запустить его в октаве, так как я застрял на отфильтрованном демоде, поскольку Octave говорит, что формат отличается ... Как я могу отобразить их в домене freq?

Код следующий

% Parameters
Fs = 44100;
T  = 1;
Fc = 15000;
Fm = 10;

% Low-pass filter design
[num,den] = butter(10,1.2*Fc/Fs); 

% Signals
t = 0:1/Fs:T;
x = cos(2*pi*Fm*t);
y = ammod(x,Fc,Fs);
z = amdemod(y,Fc,Fs);
w = amdemod(y,Fc,Fs,0,0,num,den); 

% Plot
figure('Name','AM Modulation');
subplot(4,1,1); plot(t,x); title('Modulating signal');
subplot(4,1,2); plot(t,y); title('Modulated signal');
subplot(4,1,3); plot(t,z); title('Demodulated signal');
subplot(4,1,4); plot(t,w); title('Demodulated signal (filtered)');

Ответы [ 2 ]

0 голосов
/ 02 апреля 2020

В Octave amdemod из пакета communications разрешают только три входных аргумента, которые можно просмотреть, когда вы используете type amdemod:

## Copyright (C) 2007 Sylvain Pelissier <sylvain.pelissier@gmail.com>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{m} =} amdemod (@var{s}, @var{fc}, @var{fs})
## Compute the amplitude demodulation of the signal @var{s} with a carrier
## frequency of @var{fc} and a sample frequency of @var{fs}.
## @seealso{ammod}
## @end deftypefn

function m = amdemod (s, fc, fs)

  if (nargin != 3)
    print_usage ();
  endif
  t = 0:1./fs:(length (s) - 1)./fs;
  e = s .* cos (2.*pi.*fc.*t);
  [b a] = butter (5, fc.*2./fs);
  m = filtfilt (b, a, e).*2;

endfunction

%% Test input validation
%!error amdemod ()
%!error amdemod (1)
%!error amdemod (1, 2)
%!error amdemod (1, 2, 3, 4)

В этом смысле строка w = amdemod(y,Fc,Fs,0,0,num,den) не проходит, так как количество входных аргументов не 3.

0 голосов
/ 02 апреля 2020

ammod (https://octave.sourceforge.io/communications/function/ammod.html) в пакете Octave для «коммуникаций», который вам, возможно, придется установить или загрузить. Вы найдете пакет на https://octave.sourceforge.io/communications/index.html и инструкции по установке любого пакета на https://octave.org/doc/interpreter/Installing-and-Removing-Packages.html

...