comparing strings

3 次查看(过去 30 天)
kash
kash 2012-1-21
i have set of values,
A=[1:1:80]
B=1
now i want to convert into strings and then compare,if the values are same it should display 1 else 0
  5 个评论
Walter Roberson
Walter Roberson 2012-1-22
Yes? And why does that require comparing as strings instead of as numeric values?
Jan
Jan 2012-1-22
How can 2 values be equal, if B is only a scalar? Is A not necessarily unique?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2012-1-23
for K = 1 : length(A)
results(K) = 0 + strcmp(num2str(A(K)), num2str(B));
end
I still think this is not good programming practice, but you asked and here it is.

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by