MATLAB Answers

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)

3 views (last 30 days)
Raghu dharahas reddy kotla
Edited: Stephan on 8 Dec 2019
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 Comment

dpb
dpb on 8 Dec 2019
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

Sign in to comment.

Answers (1)

Stephan
Stephan on 8 Dec 2019
Edited: Stephan on 8 Dec 2019
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

  0 Comments

Sign in to comment.

Sign in to answer this question.