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 日間)
Raghu dharahas reddy kotla
Raghu dharahas reddy kotla 2019 年 12 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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