I would like to transmit an encoded image using USRP. The first step is to load the image using Matlab and encode it. The respective codes are shown as follows.
function msg = genMsg1
%#codegen
persistent msgStrSet count;
if isempty(msgStrSet)
count = 0;
msgStrSet = imread('cameraman.tif'); % Load the image of cameraman.tif
end
msgtemp = dec2bin(msgStrSet); % Covert msgStrSet into binary value
msg_1ine = msgtemp(count+1,:).'; % Take msgtemp line by line and tranpose it
msg = str2num(msg_1ine); % Convert each line from string into column vector
count = mod(count+1,65536);
end
And the running result of this M-file is: ans =
1
0
1
0
0
0
0
0
Since I should use the block of SDRU transmitter, I have to encode above codes into a matlab function, which is shows as following figure.
But when I run this block, error windows pops up, as the following figure shows.
The first error is:
Subscripting into an mxArray is not supported.
Function 'MATLAB Function' (#46.311.329), line 11, column 12:
"msgtemp(count+1,:)"
Launch diagnostic report.
The second error is
Undefined function or variable 'msg_1ine'. The first assignment to a local variable determines its class.
Function 'MATLAB Function' (#46.391.399), line 12, column 15:
"msg_1ine"
Launch diagnostic report.
The third error and fourth error are the same.
Errors occurred during parsing of MATLAB function 'MATLAB Function'(#45)
I think the second, third and fourth errors are due to the first error,
Subscripting into an mxArray is not supported.
I have search the internet for the whole day, and still could not find the similar problem. Could anyone tell me what is "Subscripting into an mxArray is not supported" after all and how to solve it?
Thanks in advance for any leading!