我想檢查字符串長度超過20個字符,如果大於20則返回1,否則以矩陣形式返回0 [n x 1]。但是現在,我得到了[1x1]的答案。如何在if-else語句中修改我的代碼以獲取答案?Matlab:如何檢查長度超過某個數字的字符串
str = {'http://www.mathworks.com/matlabcentral/newsreader/view_thread/324182',
'http://jitkomut.lecturer.eng.chula.ac.th/matlab/text.html',
'http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Introduction%20to%20Matlab2.pdf'};
a = cellfun(@length,str)
if a > 20
'1'
else
'0'
end
輸出: A =
68
57
83
ans =
1
我想要的輸出,可以說
ans =
1
1
1