How to compare tables/cells/characters?

Is there any way to compare (greater than or less than) using tables? Or is there a way to compare using cells or as a character? The data being compared are numbers of various length.

답변 (1개)

Seyedali Mirjalili
Seyedali Mirjalili 2018년 3월 2일

0 개 추천

Does the following help?
tf = strcmp(s1,s2) compares s1 and s2 and returns 1 (true) if the two are identical and 0 (false) otherwise. Text is considered identical if the size and content of each are the same. The return result tf is of data type logical. The input arguments can be any combination of string arrays, character vectors, and cell arrays of character vectors.

댓글 수: 4

I know that my strings/characters/cells will never be equal, I am hoping to see which is greater than the other
What is your definition for one string being greater than a second string? For each of these examples, which one is greater and why?
A = 'apple'; B = 'banana';
A = 'apple'; B = 'applesauce';
A = 'apple'; B = 'app';
A = 'apple'; B = 'APPLE';
A = 'them apples'; B = 'the mapples';
As stated in my original question I am comparing cells/characters/strings that are numbers
Stephen23
Stephen23 2018년 3월 2일
@Lexington Stoyell: only numeric values can be considered to have the property greater/less than. Convert the strings to numeric if you want to make this comparison.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2018년 3월 1일

댓글:

2018년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by