Errore matlab function oscillatore megafunction
Salve a tutti sto lavorando ad un progetto che prevede l'utilizzo di una scheda montata su FPGA che effettua conversione AD/DA
Nelle dimostrazioni vi sono due file che restituiscono un errore:
Questo è il codice che ho trovato sul cd:
Qui vi è il test:
Per compilare il codice ho semplicemente aperto il file di test e sono andato su run. Il problema che riporta degli errori:
come posso risolvere? grazie a tutti per l'aiuto
Nelle dimostrazioni vi sono due file che restituiscono un errore:
Questo è il codice che ho trovato sul cd:
- Codice: Seleziona tutto
% Altera NCO version 9.0
% function [s,c] = nco91_model(phi_inc_i,phase_mod_i,freq_mod_i)
% input : phi_inc_i : phase increment input (required)
% phase_mod_i : phase modulation input(optional)
% freq_mod_i : frequency modulation input(optional)
% output : s : sine wave output
% c : cosine wave output
function [s,c] = nco91_model(phi_inc_i,phase_mod_i,freq_mod_i)
addpath c:/altera/91/ip/altera/nco/lib/ip_toolbench/../;
if(nargin==0)
fprintf('Error using nco91_model : Not enough input arguments\n');
else
N=length(phi_inc_i);
end
if(nargin==1)
phase_mod_i=zeros(1,N);
freq_mod_i=zeros(1,N);
elseif(nargin==2)
if(length(phase_mod_i)~=N)
fprintf('Error using nco91_model : input vector length mismatch\n');
else
freq_mod_i=zeros(1,N);
end
elseif(nargin==3)
if((length(phase_mod_i)~=N)|length(freq_mod_i)~=N)
fprintf('Error using nco91_model : input vector length mismatch\n');
end
else
fprintf('Error using nco91_model : Incorrect number of input arguments\n');
end
N=length(phi_inc_i);
numch = 1.0;
apr = 32.0;
apri = 24.0;
mpr = 13.0;
aprp = 16.0;
aprf = 32.0;
dpri = 5.0;
arch = 2.0;
wantFmod = 0.0;
wantPmod = 0.0;
dual = 1.0;
[s,c] = Sncomodel(phi_inc_i,phase_mod_i,freq_mod_i,wantFmod,wantPmod,numch,apr,mpr,apri,aprp,aprf,dpri,arch,dual,N);
Qui vi è il test:
- Codice: Seleziona tutto
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Altera NCO version 9.0
% file : nco91_tb.m
%
% Description : The following Matlab testbench excercises the NCO model nco91_model.m
% generated by Altera's NCO Megacore and outputs the sine and cosine waveforms
% to the variables sin_out and cos_out respectively
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parameter description
% N : the length of input and output arrays
% fs : the desired sampling rate. For Multi-channel NCO's the channelized sample rate is fs/M
% ehre M is the number of channels
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N=2048*1;
fs = 1.0E8;
% Input arrays
% phi_inc_i : input phase increment : Length N (required)
phi_inc_i = 42949673.*ones(1,N);
% freq_mod_i : frequency modulation input : Length N (optional)
freq_mod_i = zeros(1,N);
% phase_mod_i : phase modulation input : Length N (optional)
phase_mod_i = zeros(1,N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function call to generated nco function
[sin_out,cos_out] = nco91_model(phi_inc_i,phase_mod_i,freq_mod_i);
fid_s = fopen('fsin_o_nco91_matlab.txt','w');
fid_c = fopen('fcos_o_nco91_matlab.txt','w');
for i=1:N
fprintf(fid_s,'%f\n',sin_out(i));
fprintf(fid_c,'%f\n',cos_out(i));
end
% Plot Channel 0 Time-Domain Output
xvalst = (0:1/fs:((N/1)-1)/fs);
figure,stairs(xvalst,sin_out(1:1:N),'r');
hold on, stairs(xvalst,cos_out(1:1:N),'b');
legend('sine','cosine');
title ('Time-Domain Plot of NCO Channel 0 Output');
grid on;
zoom on;
xlabel ('Time');
ylabel ('Amplitude');
ncofftwinplot(sin_out(1:1:N),fs,0,'r');
ncofftwinplot(cos_out(1:1:N),fs,1,'b');
Per compilare il codice ho semplicemente aperto il file di test e sono andato su run. Il problema che riporta degli errori:
- Codice: Seleziona tutto
CODICE: SELEZIONA TUTTO
>> nco91_model
Error using nco91_model : Not enough input arguments
Error using nco91_model : Incorrect number of input arguments
Not enough input arguments.
Error in nco91_model (line 31)
N=length(phi_inc_i);
>>
come posso risolvere? grazie a tutti per l'aiuto