Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

hi,i am getting error as not enough input arguments,while i run the below code....?? please let me know that?(the error is in second line of code)

조회 수: 1 (최근 30일)
function [x]=trio(m,n)
x=rand([3*m n]);
x(1:3*m/3,:)=1;
x(3*m/3+1:3*m/3+m,:)=2;
x(3*m/3+m+1:end,:)=3;
end
  댓글 수: 1
dpb
dpb 2019년 12월 8일
Works fine here. Show us how you called it.
NB: 3*m/3 --> m so the above could be more succinctly written as
function [x]=trio(m,n)
x=rand([3*m n]);
x(1:m,:)=1;
x(m+1:2*m,:)=2;
x(2*m+1:end,:)=3;
end

답변 (1개)

Stephan
Stephan 2019년 12월 8일
편집: Stephan 2019년 12월 8일
Works fine for me, if called with 2 input arguments:
res = trio(3,4)
function x=trio(m,n)
x=rand([3*m n]);
x(1:3*m/3,:)=1;
x(3*m/3+1:3*m/3+m,:)=2;
x(3*m/3+m+1:end,:)=3;
end

Community Treasure Hunt

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

Start Hunting!

Translated by