Cell array and num2str comparison
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I want to know the diiference in the attacehd image, ass well i would like to know how to convert [] to '' the strcamp will work well.
groupName = [11,12];
a = num2cell(groupName)
c = {'42', '12'}
rows = strcmp(a,c)
thanks,
Nadav
0 个评论
采纳的回答
Jan
2022-9-11
The variable a is a cell array containing 2 scalar numbers, while b contains 2 CHAR vectors.
a = {42, 12}
c = {'42', '12'}
The square brackets are shown in the command window only an converting them to quotes is not meaningful.
There are many ways to compare the two cell arrays:
a1 = [a{:}];
c1 = str2double(c)
a1 == c1
or
a2 = sprintfc('%d', [a{:}])
strcmp(a2, c)
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!