Function output 'y' cannot be an mxArray in this context. Consider preinitializing the output variable with a known type

27 ビュー (過去 30 日間)
function y = fcn(u)
coder.extrinsic('imwrite');
y = imwrite(u,'testOutput.bmp');
I want to convert a jpg image to bmp image in simulink model. Tried doing through mathlab function but it is throwing this error. Can you please help me through this!

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 15 日
編集済み: Walter Roberson 2018 年 4 月 15 日
imwrite() never returns a value. The way the imwrite() function is defined prevents it from returning a value.
  11 件のコメント
Walter Roberson
Walter Roberson 2018 年 4 月 25 日

How do you know the input image is portrait ? If you imread() it and image() it at the MATLAB level does it show up as portrait?

The reason I ask is that JPEG images in particular can have an Orientation EXIF header that tells the presentation software that data that is stored as landscape should be displayed as portrait. When you have a landscape image and you use a tool to rotate the image by 90 degrees, sometimes instead of rewriting the data matrix, the tools just write in a new Orientation header. But imread() does not pay any attention to the Orientation header and would use the way the data is stored.

Nagendar Reddy
Nagendar Reddy 2018 年 7 月 31 日
Hi, I am also facing same problem "function output cannot be a mxarray, Consider preinitializing the output variable with a known type". In my application I am assigning output of "cat /dev/serial" output to M-function output. My command "cat /dev/serial" always returns 20 bytes data. So how i have to define length & type of my function output

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by