MATLAB Answers


Hi, I want to transmit an image using Simulink and USRP. I have the following code. But when I run this code, MATLAB produces following error. How can ı fix this problem?

Asked by Volkan
on 5 Feb 2013

function msg = genMsg %#codegen persistent imgmatRows imgmatCols imgvec msgBin msgBinRows msgBinCols msgTmp;

coder.extrinsic('imread'); % count; if isempty(imgvec) %count = 0; imgmat = imread('cameraman.tif'); [imgmatRows, imgmatCols] = size(imgmat); imgvec = reshape(imgmat, 1, imgmatRows * imgmatCols); msgBin = de2bi(int8(imgvec), 7, 'left-msb'); [msgBinRows, msgBinCols] = size(msgBin); msgTmp = reshape(double(msgBin).', msgBinRows*msgBinCols, 1); end

msg = msgTmp; Error message: "Function output 'y' cannot be an mxArray in this context. Consider preinitializing the output variable with a known type."


No products are associated with this question.

0 Answers

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!