I'm trying to create a function that will only accept a matrix
1 次查看(过去 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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!