Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
error in questdlg loop

Subject: error in questdlg loop

From: Kenan

Date: 30 Apr, 2010 21:48:02

Message: 1 of 3

Hi everyone!

I want to create a Yes - No dialogbox within my .m code. I've made it using a "while" loop. There is no problem if you choose "Yes" on the dialog box. But i get this error when i choose "No":

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

Error in ==> sayisal2 at 175
    while choice=='Yes'

Here is the whole code. This is a code which shows the rows of the matrix begin with the number defined by user:

A=[19 20 26 28 31 46;
9 11 14 31 40 45;
1 6 14 27 39 49;
13 21 26 27 33 47;
8 12 15 17 27 31;
22 23 24 25 40 47;
2 7 18 22 36 37];

a=input('Write the first number: ');
while a==0 | a>49
    a=input('Please enter a number between 0 and 49 ');
end
    Z=A(A(:,1)==a,:)
    disp(Z)
    disp([num2str(size(Z,1)) ' matches found.'])
    str='Do you want to try again?';
    choice=questdlg(str,'New process','Yes','No','Yes');

    while choice=='Yes'
            a=input('Write the first number: ');
            while a==0 | a>49
            a=input('Please enter a number between 0 and 49 ');
            end
    Z=A(A(:,1)==a,:);
    disp(Z)
    disp([num2str(size(Z,1)) ' matches found.'])
    str='Do you want to try again?';
    choice=questdlg(str,'New process','Yes','No','Yes');

    end

Any help would be appreciated. Thanks in advance.
Kenan

Subject: error in questdlg loop

From: ImageAnalyst

Date: 30 Apr, 2010 21:59:20

Message: 2 of 3

Kenan
Try using strcmpi(choice, 'yes') instead of choice == 'Yes'

Subject: error in questdlg loop

From: Kenan

Date: 1 May, 2010 11:23:05

Message: 3 of 3

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <09dd3398-293e-4353-8b63-bf508655a305@d12g2000vbr.googlegroups.com>...
> Kenan
> Try using strcmpi(choice, 'yes') instead of choice == 'Yes'
>
Thanks a lot. It works.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us