Help in SIMULINK
Hello all,
I am in the process of making my own convolutional code block
in User defined blocks using 'Embedded MATLAB function', in Simulink.
But i encounter some errors. The dilemma is the code runs perfectly
in MATLAB but not in SIMULINK.
The code is here :-
function c = encode(m)
% Main code for the encoder- Convolutional Encoder
%Initialize Simulation Parameters
R = 1/3; % code rate
dbs = -1:10; % SNR per bit, in dB
%
%Define Impulse response for the n generators for a 1/n code - here n=3
g{1} = [1 0 1 1 0]; % Impulse Responses _ 1
g{2} = [1 1 0 1 0]; % Impulse Responses _ 2
g{3} = [1 1 1 1 0]; % Impluse Responses _ 3
n = length(g); % Convolution Code (1/n) parameter
memory_els = 3;
%---
%
ENCODER: 1/3 Convolution Encoder
%
c = encode_1_3(m,g,n)
%
%
function c = encode_1_3(m,g,n)
%Function: Encodes a Rate 1/3 Convolution Code
%m = message to encode
%g = n generators corresponding to the n outputs
%n = 1/n Convolution Encoder -- # of generators
%First Perform Convolution of Input Message for Each Generator. This
%produces n outputs... [y{1},y{2},...,y{n}]
for i = 1:n
y{i} = mod(conv(m,g{i}),2);
end
%Initialize code word to all zeros
c = zeros(1,n*length(y{1}));
%Assemble code word from n outputs
for i = 0:n-1
c(1+i:n:end) = y{i+1};
end
and the errors i get are
Unsupported: cell arrays function in 'Convolutional_Encoder'
in lines shown in brown in the code.
plss help
[IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-1.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-3.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-4.jpg[/IMG]
[IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-2.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-5.jpg[/IMG]
[IMG]file:///C:/Users/NIDHI/Desktop/IITD%20Intern/Project/conv_encoder/errors.jpg[/IMG][IMG]file:///C:/Users/NIDHI/Desktop/IITD%20Intern/Project/conv_encoder/errors.jpg[/IMG]
I am in the process of making my own convolutional code block
in User defined blocks using 'Embedded MATLAB function', in Simulink.
But i encounter some errors. The dilemma is the code runs perfectly
in MATLAB but not in SIMULINK.
The code is here :-
function c = encode(m)
% Main code for the encoder- Convolutional Encoder
%Initialize Simulation Parameters
R = 1/3; % code rate
dbs = -1:10; % SNR per bit, in dB
%
%Define Impulse response for the n generators for a 1/n code - here n=3
g{1} = [1 0 1 1 0]; % Impulse Responses _ 1
g{2} = [1 1 0 1 0]; % Impulse Responses _ 2
g{3} = [1 1 1 1 0]; % Impluse Responses _ 3
n = length(g); % Convolution Code (1/n) parameter
memory_els = 3;
%---
%
ENCODER: 1/3 Convolution Encoder
%
c = encode_1_3(m,g,n)
%
%
function c = encode_1_3(m,g,n)
%Function: Encodes a Rate 1/3 Convolution Code
%m = message to encode
%g = n generators corresponding to the n outputs
%n = 1/n Convolution Encoder -- # of generators
%First Perform Convolution of Input Message for Each Generator. This
%produces n outputs... [y{1},y{2},...,y{n}]
for i = 1:n
y{i} = mod(conv(m,g{i}),2);
end
%Initialize code word to all zeros
c = zeros(1,n*length(y{1}));
%Assemble code word from n outputs
for i = 0:n-1
c(1+i:n:end) = y{i+1};
end
and the errors i get are
Unsupported: cell arrays function in 'Convolutional_Encoder'
in lines shown in brown in the code.
plss help
[IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-1.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-3.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-4.jpg[/IMG]
[IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-2.jpg[/IMG][IMG]file:///C:/Users/NIDHI/AppData/Local/Temp/moz-screenshot-5.jpg[/IMG]
[IMG]file:///C:/Users/NIDHI/Desktop/IITD%20Intern/Project/conv_encoder/errors.jpg[/IMG][IMG]file:///C:/Users/NIDHI/Desktop/IITD%20Intern/Project/conv_encoder/errors.jpg[/IMG]
0