problem in writing a function

조회 수: 1 (최근 30일)
Bijoy
Bijoy 2013년 6월 16일
What is the problem with this code?
function Y = BWMfn(B)
[m,n]=size(B);
Y=zeros(2*m,2*n);
for i=1:m;
for j=1:n;
if B(i,j)<128
Y(2*i-1,2*j-1)=0;
else
Y(2*i-1,2*j-1)=1;
end
end
end
BWM is a matrix. Please reply asap
  댓글 수: 1
Bijoy
Bijoy 2013년 6월 16일
I am getting this error:
Error using BWMfn (line 3)
Not enough input arguments.

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

채택된 답변

Image Analyst
Image Analyst 2013년 6월 16일
Why do you even want this anyway? It's kind of like simple thresholding
Y = B >= 128;
except that it has rows and columns of zeros interleaved. Why would you want that? By the way, you could vectorize it by doing:
Y = zeros(2*size(B));
Y(1:2:end, 1:2:end) = B >= 128;
  댓글 수: 1
Bijoy
Bijoy 2013년 6월 16일
I want the function in some other code for the purpose of data embeding. The function should do thresholding and give elements of the vector as Its output one by one. But the problem is I have to use the function within Some other loop.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 6월 16일
You need to start the function from the command line, not by clicking on "Run" or pressing F5. For example at the command line command
BWMfn(rand(3,4))

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by