CONVOLUTION process with the HDL simulink blocks, does not giving the similar output for the MATLAB script output (highvariations between the simulink and script output))

5 views (last 30 days)
i tried with both methods, passing the fixed point coversion values of convolute signal and filter coefficent & double complex values of the signla and filter coefficeint. but in the both scenarios im getting the simulink values higher than script output. can anyone find the error encounted in the case,
Here is my code
%% CONVOLUTION
first_nprach_filtered = conv(2*Reversed_NCO_for_NPRACH, nprach_recover_from_20);
% matrix reverse
first_nprach_filtered = first_nprach_filtered';
%signal length
time = length(first_nprach_filtered);
%% COVERTING THE COEFFICENT TO FIXED POINT VALUES (OPTIONAL)
Reversed_NCO_for_NPRACH = Reversed_NCO_for_NPRACH/max(Reversed_NCO_for_NPRACH);% bring the values between 1 & -1 for the simlicity
Reversed_NCO_fixed = fi(Reversed_NCO_for_NPRACH,1,16,14);% set word length and fractional length for fixed convertion
first_nprach_filtered = first_nprach_filtered/max(first_nprach_filtered);
nprach_recover_from_20 = 2*nprach_recover_from_20/max(2*nprach_recover_from_20);% make sure coefficents are between 1 & -1
nprach_fixed_point = fi(nprach_recover_from_20,1,16,14);%fixed point convertion of filter coefficients
%% RUN THE SYSTEM AND ABSTRACT THE SIMULINK OUTPUT DATA
% Run HDL FFT model
open_system("subsystem_simlunik_conv.slx")
sim("subsystem_simlunik_conv.slx")
% Get output of HDLFFT model
logsout = sim('subsystem_simlunik_conv');
hdlfft_data = logsout.get('simout');
%% MAXIMUM REAL AND IMAGINARY VALUES AND MAXIMUM VALUE DIFFERENCE BETWEEN SCRIPT AND SIMULINK
fft_diff = first_nprach_filtered(1:time)-hdlfft_data(1:time);
%maximum real and imaginary of script workspace data
fprintf("Max_real_script_out %f\n", max(real(first_nprach_filtered)));
fprintf("Max_imag_script_out %f\n", max(imag(first_nprach_filtered)));
fprintf("\n")
% maximum real and imaginary values of simulink data
fprintf("Max_real_simulink_out %f\n", max(real(hdlfft_data)));
fprintf("Max_imag_simulink_out %f\n",max(imag(hdlfft_data)));
fprintf("\n")
% maximum real and imaginary values of difference between
% script value and simulink value
fprintf("Max real diff is %f\n", max(real(fft_diff)));
fprintf("Max imag diff is %f\n", max(imag(fft_diff)));
Here is the command output showing the real and imag of script output , simulink output and difference of sscript and simulink output,
Max_real_script_out 1.000000
Max_imag_script_out 0.958354
Max_real_simulink_out 1.999939
Max_imag_simulink_out 1.999878
Max real diff is, 2.894426
Max imag diff is, 2.885388

Accepted Answer

Kiran Kintali
Kiran Kintali on 28 Jul 2023
Edited: Kiran Kintali on 28 Jul 2023
Caused by:
Error using slhdlcoder.SimulinkConnection/initModel
Error evaluating parameter 'X' in 'subsystem_simlunik_conv/Signal From
Workspace'
Error using slhdlcoder.SimulinkConnection/initModel
Unrecognized function or variable 'Reversed_NCO_fixed'.
Error using slhdlcoder.SimulinkConnection/initModel
Variable 'Reversed_NCO_fixed' does not exist.
I think we need to run the script for the missing setup. Attached zip file has file.
  2 Comments
Fayaz
Fayaz on 28 Jul 2023
Edited: Fayaz on 28 Jul 2023
did you run the script after running the
to the workspace, then the real and imag values of the script and simulink outputs coming in the command line. The issue is the simulink output is not matchin with script output. can you find the error encounted in the simulink block set?
can you point out the error which makes the output to differ from each other?

Sign in to comment.

More Answers (0)

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!