if statement with message display

i want to make if statement and if this true printf this message and elseif do the same but when i try to use msgbox it doesn't work true and disp doesn't work
count1 = sum(data(:) >=0.8);
count2=sum(data(:)<0.8);
count3=sum(data(:)<=0.5);
count6=sum(data(:)<0.7 &data(:)>=0.6);
count7=sum(data(:)<0.8 & data(:)>=0.7);
if(count2>count1 && count3>count6 && count3>count7)
message1 = sprintf('This is sickle cell: %d',count3);
elseif (count2>count1 && count6>count3 && count6 >count7)
message1 = sprintf('This is elliptocytes cell: %d',count6);
elseif (count2>count1 && count7>count3 && count7 >count6);
message1 = sprintf('This is echinocytes cell: %d',count7);
end;
msgbox=({message1});

 Respuesta aceptada

Star Strider
Star Strider el 16 de Jun. de 2015
Try:
h = msgbox(message1);

4 comentarios

menna gamal
menna gamal el 16 de Jun. de 2015
i also try it and try to wrote msgbox() directly in each condition with no result
Star Strider
Star Strider el 16 de Jun. de 2015
I am not certain what you did.
First, do not name any of your variables ‘msgbox’. Delete that line. This is called ‘shadowing’ (or ‘overshadowing’) and MATLAB will throw an error if you call the msgbox function after you have assigned it as a variable, so the msgbox function call after that will not work correctly.
Does your ‘msgbox()’ call create a message box even without the text? (Be sure you give the msgbox function an argument.)
If you copy my code and paste it into your code after the if block, does it produce a message box with the appropriate text?
menna gamal
menna gamal el 16 de Jun. de 2015
thanks, i solve it by wrote clear all; in the top of the code
Star Strider
Star Strider el 16 de Jun. de 2015
My pleasure.
I’m glad you got it working.

Iniciar sesión para comentar.

Más respuestas (1)

B.k Sumedha
B.k Sumedha el 16 de Jun. de 2015
Editada: B.k Sumedha el 16 de Jun. de 2015
After each message1 put the msgbox.
U can just use
msgbox(message1);

5 comentarios

menna gamal
menna gamal el 16 de Jun. de 2015
i try it and doesn't work , no output !
B.k Sumedha
B.k Sumedha el 16 de Jun. de 2015
Editada: B.k Sumedha el 16 de Jun. de 2015
Did u get any error?
No,
Error: Index exceeds matrix dimensions.
Error in clustring (line 137)
msgbox(message4);
This error happened when i try this and try else for first if :
if(count2>count1 )
if( count3>count6 && count3>count7)
message1 = sprintf('This is sickle cell: %d',count3);
msgbox(message1);
elseif ( count6>count3 && count6 >count7)
message2 = sprintf('This is elliptocytes cell: %d',count6);
msgbox(message2);
elseif ( count7>count3 && count7 >count6);
message3 = sprintf('This is echinocytes cell: %d',count7);
msgbox(message3);
end;
else
message4 = sprintf('This is Normal cell');
msgbox(message4);
end;
menna gamal
menna gamal el 16 de Jun. de 2015
i solve it by wrote clear all; in the top of the code

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Jun. de 2015

Comentada:

el 16 de Jun. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by