Getting multiple outputs on a single variable in MATLAB function block inside simulink.

조회 수: 5 (최근 30일)
Hello.
I'm trying to create a simple MATLAB function block that takes an input 2D matrix (image), and extracts all the rows from this image, outputting them one-by-one into the rest of the simulink model for row-based processing (model to go through HDL coder for FPGA implementation at the end). The problem is that when this is being run inside of simulink, only the last row is being outputted to the rest of the pipeline. How can I fix this function such that it outputs the first row for a bit, then the second row for a bit and so on. I've tried delay blocks in Simulink but I think the modification needs to be done within this MATLAB function block .This is what I have currently:
function row_out = row_extractor(img_dat, start, nrows, ncols)
persistent row_inter;
if isempty(row_inter)
row_inter = uint32(zeros(1, ncols));
end
persistent row_dat;
if isempty(row_dat)
row_dat = uint32(zeros(1, ncols));
end
row_out = uint32(zeros(1, 3));
if start == true
for row_index = 1 : nrows
for pixel_index = 1 : ncols
row_dat(pixel_index) = img_dat(row_index, pixel_index);
row_out(pixel_index) = row_dat(pixel_index);
%pause(1);
end
end
end
end

답변 (1개)

Kiran Kintali
Kiran Kintali 2021년 6월 30일
Use this example to see how to extract a port of the image to stream into DUT suitable for HDL Code Generation.
  댓글 수: 1
Albin Grip
Albin Grip 2021년 6월 30일
Hi Kiran, thanks for your reply.
My question is more so related to how to get the different function blocks to run a different number of times within one cycle. So basically theres a 2d matrix (image input) that I want to extract row-by-row (one function call), and for each of those rows theres a processing MATLAB function (so that needs to be called for nrows times), hence a 1:nrows ratio. And after this the cycle repeats with a new image and so forth.
Where as in the example you sent its more so that the each function block (capture column data, median filter and update image) gets called once every clock cycle 1:1:1 ratio to process each pixel individually in the frame.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 HDL Coder에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by