function in simulink matlab function block is not bounded

조회 수: 1 (최근 30일)
Daniel Delannes-molka
Daniel Delannes-molka 2023년 7월 11일
댓글: Daniel Delannes-molka 2023년 7월 12일
I'm trying to figure about using convhulln in simulink for my own purposes and came across and error when running this code in an matlab function block in simulation mode:
function K = fcn()
P = rand(10,3);
K = zeros(12,3);
V = convhulln(P);
K(:,:) = V(1:12,:);
end
I'm aware of this sort of error and its why I preallocated K to an array of [12,3] and only pushed 12 values from V. But the error is not originating from the input or output of my own function, reather it seem that convhulln is causing this issue. Unless I'm miss reading https://www.mathworks.com/help/simulink/ug/control-memory-allocation-for-variable-size-arrays-in-a-matlab-function-block.html I can't think of how to make their suggestions apply to functions calls within a matlab function block where the size of the inputs to convhulln are static. Any idea of what I might not be considering?
  댓글 수: 2
Paul
Paul 2023년 7월 12일
Hi Daniel,
What is the utility outputting only the first 12 rows of V? What if K has more than 12 rows?
rng(100)
size(convhulln(rand(10,3)))
ans = 1×2
16 3
Daniel Delannes-molka
Daniel Delannes-molka 2023년 7월 12일
12 is absolutly arbitrary, I need a static size array output so I set it 12 for testing. When i'm sure the function will work I will probrably be more intelligent about the array size. something like this(or just setting K to be a variable size array):
function [K,s] = fcn()
P = rand(10,3);
K = zeros(128,3);
V = convhulln(P);
s = size(V,1);
K(1:s,:) = V(1:s,:);
end

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

답변 (1개)

Angelo Yeo
Angelo Yeo 2023년 7월 12일
Yesterday, when I looked into your previous question, I tried to fix the model. Please take a look and compare it with yours. See the attachment.
  댓글 수: 1
Daniel Delannes-molka
Daniel Delannes-molka 2023년 7월 12일
It appears to be running into the exact same error I got above when run in simulation. With regrad to hardware mode(monitor and tune) I see that you are using the ert.tlc. Initaly, it did not work but when I set the code interfacing packaging to nonreusable function I ended up with the same error as above as well.

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

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by