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:
Input box

Subject: Input box

From: Maha K

Date: 18 Sep, 2007 16:42:39

Message: 1 of 7

Hi ,

I am working on some calculations using Matlab and I
have 'X' which changes depending on what I want from the
calculation. in order to complete the calculation, I would
like to know if I could bring up a box which will ask me
for a value for 'X' instead of having to define it in the
body of the m-file? Something like a pop up box where I
could insert a value?

Thanks in advance!

M

Subject: Input box

From: David

Date: 18 Sep, 2007 16:49:59

Message: 2 of 7

"Maha K" <maha_k@mathworks.com> wrote in message
<fcov5v$csm$1@fred.mathworks.com>...
> Hi ,
>
> I am working on some calculations using Matlab and I
> have 'X' which changes depending on what I want from the
> calculation. in order to complete the calculation, I
would
> like to know if I could bring up a box which will ask me
> for a value for 'X' instead of having to define it in
the
> body of the m-file? Something like a pop up box where I
> could insert a value?
>
> Thanks in advance!
>
> M

check out the 'input' command.

Subject: Input box

From: Jerome Briot

Date: 18 Sep, 2007 16:51:24

Message: 3 of 7

Hi,

help inputdlg

Jérôme

Subject: Input box

From: Maha K

Date: 18 Sep, 2007 22:27:40

Message: 4 of 7

Thank you! that was useful. I've managed to get it working.
I have just another question...

If I were to ask this dialog box to turn up within a loop
and would like to use the value or string assigned to it
for every time it loops through, how would I make the
dialog box to appear just once within the loop (rather than
everytime the code goes through the loop) and use the same
answer for the remaining times it loops through the main
loop? Can this be done?

Thanks in advance!

Subject: Input box

From: Maha K

Date: 18 Sep, 2007 22:28:41

Message: 5 of 7

Thank you! that was useful. I've managed to get it working.
I have just another question...

If I were to ask this dialog box to turn up within a loop
and would like to use the value or string assigned to it
for every time it loops through, how would I make the
dialog box to appear just once within the loop (rather than
everytime the code goes through the loop) and use the same
answer for the remaining times it loops through the main
loop? Can this be done?

Thanks in advance!

Subject: Input box

From: Maha K

Date: 18 Sep, 2007 22:30:59

Message: 6 of 7

My last reply didn't seem to get posted.

thanks for the replies guys! that was useful and I've
managed to get the dialogue box into my code.

I just have another question : if I were to use the dialog
box within a loop, is there anyway I could just restric the
dialogue box to pop up just once (instead of every time the
code loops through) and use that one value for the
remaining number of times the code loops through?

Thank in advance!

Subject: Input box

From: dpb

Date: 18 Sep, 2007 22:41:09

Message: 7 of 7

Maha K wrote:
> My last reply didn't seem to get posted.

Yes it did...three times, so far. Just give things time to percolate
through the servers...

...

> I just have another question : if I were to use the dialog
> box within a loop, is there anyway I could just restric the
> dialogue box to pop up just once (instead of every time the
> code loops through) and use that one value for the
> remaining number of times the code loops through?

Not sure what you're really asking, but unless you branch around code in
a loop it will be executed each time through. So, the lesson to be
learned is, if you don't want code executed each time through a loop,
don't put it in a loop to start with...

If you display the dialog before the loop and save the response,
whatever variable the response is placed in won't change value unless
and until you use it for some other purpose. So, seems to me your
question boils down to saving the response...unless, of course, the
intent is totally different than I interpret the question...

--

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