I'm trying to create a function that will only accept a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm not really sure how to go about this challenge. I know something is wrong with my output and function but I do not really know how to work it etc.
start
function output=rowcolumn(x,y)
if length(x)==length(y) disp('yes')
if length(x)>length(y) disp('no')
if length(x)<length(y) disp('no')
end
댓글 수: 2
답변 (1개)
Star Strider
2016년 3월 29일
편집: Star Strider
2016년 3월 29일
I guess you’re testing for a vector lengths.
You need to use elseif to test the alternatives:
function output=rowcolumn(x,y)
if length(x)==length(y) disp('yes')
elseif length(x)>length(y) disp('no')
elseif length(x)<length(y) disp('no')
end
end
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!