MATLAB Answers


how to execute (cell) in operation (if then)? , data types: string, taken from the data excel.

Asked by Roza
on 6 Jan 2013

I want to compare two string data. but when I use the expression for and if, it can not be run.

i'm sorry... this is my code... I am a beginner, please your help.

for i=1:n_vertex
for j=1:n_vertex
   if isequal(follower{i,1}==mention{i,1}, follower{i,2}==mention{i,2})
       if follower{i,1}==wg{i,1}

============================================================================== Error using ==> eq Matrix dimensions must agree.

Error in ==> oo at 17 if isequal(follower{i,1}==mention{i,1}, follower{i,2}==mention{i,2})

================================================================================ I want to make it again from (1) to n_vertex. but it seems there is something wrong .. please help, thank you.


Walter Roberson
on 6 Jan 2013

Roza, Do not use the name of an individual as a Tag. Read the guide to tags and retag this question. See

on 6 Jan 2013

ooh hehehe... sorry, i am newbie :)... thanks for the information

Jan Simon
on 6 Jan 2013

Instead of saying sorry, it would be more efficient to edit the tag. Although there are many Jan Simon's on the earth, the most famous is a female violinist, I assume the tag means me. Therefore I feel free to delete it.

You have posted the same question already two days ago. Walter's answer suggested STRCMP() already and was accepted.

Please avoid such "double-posting", because it confuses the readers and the ones, who spend time for answering. Thanks.



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 6 Jan 2013

Do not use == to compare strings. Use strcmp()


on 6 Jan 2013

if i want ~= , what should i use to compare string?

Jan Simon
on 6 Jan 2013

As Walter has said already: Use strcmp. And if you want to check for not matching strings, use strcmp(String1, String2) == 0 or the equivalent not(strcmp(String1, String2)). Please type "help strcmp" in the command window to find out more.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!