when i used embedded matlab function for performng following code i got the error message.Here input 'Edge' from a sobel filter block,output is y

1 回表示 (過去 30 日間)
error:1)Colon operands must be all the same type, or mixed with real scalar doubles.
Function 'Embedded MATLAB Function' (#18.178.181), line 10, column 11: "imx" 2)Subscripting into an mxArray is not supported.
Function 'Embedded MATLAB Function' (#18.212.219), line 12, column 13: "Lp(i,j)" 3)Undefined function or variable 'p'. The first assignment to a local variable determines its class.
Function 'Embedded MATLAB Function' (#18.241.242), line 13, column 19: "p"
code:
function y = fcn(Edge)
eml.extrinsic('bwlabel')
[Lp,num] = bwlabel(Edge);
mx=max(max(Lp));
[px,py]=size(Edge);
[imx,imy]=size(Lp);
k=0;
for l=1:1:num
k=k+1;p(k)=0;
for i=1:1:imx
for j=1:1:imy
if Lp(i,j)==l
p(k)=p(k)+1;
end
end
end
end
q=p;
temp=0;
for i=1:1:k
for j=1:1:k-1
if p(j)>p(j+1)
temp=p(j);
p(j)=p(j+1);
p(j+1)=temp;
end
end
end
y=p(k);

採用された回答

Kaustubha Govind
Kaustubha Govind 2013 年 3 月 18 日
Since 'bwlabel' is declared as an extrinsic function and is unsupported for code-generation, the block is unable to analyze what the type and size of its outputs Lp and num are. If you pre-define their values with the expected type and size, the error should go away. For example, before calling bwlabel, you may write these lines:
Lp = zeros(size(Edge));
num = 0;
  2 件のコメント
aju
aju 2013 年 3 月 18 日
Thanx for ur answer.,when i had done what u said,following error message appeared. Embedded MATLAB Interface Error: Simulation stopped due to out of bounds error. Block Embedded MATLAB Function (#19) While executing: none
Kaustubha Govind
Kaustubha Govind 2013 年 3 月 18 日
You may want to set breakpoints in your code to see where the "Out of bounds" error occurs. Since you are indexing into a lot of variables, it is hard to tell where you're going wrong.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by