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:
popmenuap warn

Subject: popmenuap warn

From: wahyoe Unggul

Date: 29 Apr, 2011 07:41:04

Message: 1 of 2

hi all
I have some questions about "popup menu"
1. txt file
   2 3 2
   4 5 6
   1 7 2
  pushbutton1_Callback
  amj=uigetfile({' .txt'})
  no=1:(length(amj(:,1)))
  for i =no
     dropstring(i)=sprintf('%d',i)
  end
  set(handles.popupmenu1,'String',dropstring)
  This code can run, in the "dropstring" there is a warning (orange underline), whether the code is wrong in writing?

2. how that data (amj) on "pushbutton1" and data on "popupmenu1" accessible to all functions
thanks
wahyoe

Subject: popmenuap warn

From: Steven_Lord

Date: 29 Apr, 2011 13:38:59

Message: 2 of 2



"wahyoe Unggul" <wahyoe_slipnot@yahoo.co.id> wrote in message
news:ipdq2g$13u$1@fred.mathworks.com...
> hi all
> I have some questions about "popup menu"
> 1. txt file 2 3 2
> 4 5 6
> 1 7 2
> pushbutton1_Callback
> amj=uigetfile({' .txt'})
> no=1:(length(amj(:,1)))
> for i =no
> dropstring(i)=sprintf('%d',i)
> end
> set(handles.popupmenu1,'String',dropstring)
> This code can run, in the "dropstring" there is a warning (orange
> underline), whether the code is wrong in writing?

If you hover the mouse over the orange underline, you'll see why Code
Analyzer has flagged that section of code. In this case, you haven't
preallocated dropstring and so it grows each time through the loop. [Your
code also has a bug; it will not work if your file has more than 9 lines
because the string '10' has two characters, which cannot fit into a single
character in the char array dropstring. Use a cell array of strings
instead.]

> 2. how that data (amj) on "pushbutton1" and data on "popupmenu1"
> accessible to all functions

The first of these links is applicable for GUIDE-based GUIs; the second for
programmatically-created GUIs.

http://www.mathworks.com/help/techdoc/creating_guis/f5-998197.html
http://www.mathworks.com/help/techdoc/creating_guis/f13-998197.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with 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