Matlab Coder Target - Example MATLAB function for edge detection.

조회 수: 2 (최근 30일)
Abdelrahman Youssef
Abdelrahman Youssef 2020년 5월 16일
답변: Reeno Joseph 2020년 5월 21일
I am running a Matlab 2018 a with Linux Os ,
I have a raspberry PI 3 , and I would like to work with Matlab code target , so I tried the
example that is provided with the package it self .
the function is :
function myApplication()
%myApplication Example MATLAB function for edge detection.
% Copyright 2017-2018 The MathWorks, Inc.
w =,[320,240]);
d = matlab.raspi.SDLVideoDisplay;
% Main loop
kern = [1 2 1; 0 0 0; -1 -2 -1];
for k = 1:1000
img = snapshot(w);
h = conv2(img(:,:,2),kern,'same');
v = conv2(img(:,:,2),kern','same');
e = sqrt(h.*h + v.*v);
edgeImg = uint8((e > 100) * 240);
after that I intialize the connection with PI and launching the application
r= raspi
r =
raspi with properties:
DeviceAddress: 'XXXXXXXXXX'
Port: XXXX
BoardName: 'Raspberry Pi 3 Model B'
AvailableLEDs: {'led0'}
AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {'CE0','CE1'}
AvailableI2CBuses: {'i2c-1'}
AvailableWebcams: {'DEF-299 Camera (usb-3f980000.usb-1.2):','DEF-299 Camera (usb-3f980000.usb-1.3):'}
I2CBusSpeed: 100000
Supported peripherals
>> runOnHardware(r,'myApplication')
Code generation successful: View report
but I got a black screen with the screen atached to PI , any Help please why I got the black screen and how I can solve this problem ?
Thank You very Much
the following link is for the package it self

답변 (1개)

Reeno Joseph
Reeno Joseph 2020년 5월 21일
Hello Abdelrahman,
I'm guessing you are using the MathWorks customized Raspbian image.
The video display is not showing up in the HDMI due to a bug in the SDL library. For more details please refer
As a workaround, you can flash the SD card with a full version of Raspbian(with GUI) and customize it to work with MATLAB -- please follow the OS customization steps in the hardware setup screen.
I hope this helps.
Reeno Joseph


Help CenterFile Exchange에서 MATLAB Support Package for Raspberry Pi Hardware에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by