我想使用 USRP 传输编码图像。第一步是使用 Matlab 加载图像并对其进行编码。各代码如下所示。
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
而这个M文件的运行结果是:ans =
1
0
1
0
0
0
0
0
由于我要使用SDRU发射器的模块,所以我必须将上述代码编码成一个matlab函数,如下图所示。
但是当我运行这个块时,会弹出错误窗口,如下图所示。
第一个错误是:
Subscripting into an mxArray is not supported.
Function 'MATLAB Function' (#46.311.329), line 11, column 12:
"msgtemp(count+1,:)"
Launch diagnostic report.
第二个错误是
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.
第三个错误和第四个错误是一样的。
Errors occurred during parsing of MATLAB function 'MATLAB Function'(#45)
我认为第二个,第三个和第四个错误是由于第一个错误,
Subscripting into an mxArray is not supported.
我在互联网上搜索了一整天,仍然找不到类似的问题。谁能告诉我到底什么是“不支持订阅 mxArray”以及如何解决它?
提前感谢任何领导!