comparing strings

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

Oleg Komarov
Oleg Komarov 2012년 1월 21일
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
Walter Roberson
Walter Roberson 2012년 1월 21일
Why bother converting to string when you could compare the numeric value?
kash
kash 2012년 1월 22일
actually i want to diplay resultas
wen 2 values are same the resut must be one
wen 2 values are different the result mst be 0
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일

0 개 추천

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.

카테고리

태그

질문:

2012년 1월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by