Prev: cognitive radio
Next: Combining histogram and plot
From: grega on 8 Sep 2009 09:19 Hei, I would like to insert a variable in GUIDE which needs to be written in cell array for post-calculation! After running GUIDE this variable needs to be in following form,e.g. A={[1] [2] [2 3]} so that the different elements from the cell array can be acquired. Is it possible to do it any other way than implementing a table? Thank you kindly! Grega
From: qooroo on 8 Sep 2009 09:56 If it's just > A={[1] [2] [2 3]} you want then you could get the user to input [1] [2] [2 3] into an editbox and then extract the string and make it a cell in your gui code. -qooroo
From: grega on 8 Sep 2009 10:10 "qooroo " <qoorooAT(a)gmailDOT.comREMOVECAPS> wrote in message <h85npi$ee8$1(a)fred.mathworks.com>... > If it's just > > > A={[1] [2] [2 3]} > > you want then you could get the user to input [1] [2] [2 3] into an editbox and then extract the string and make it a cell in your gui code. > > -qooroo I tried it and would be great if it works...but it does not: >>A='{[1] [2] [2 3]}' A = {[1] [2] [2 3]} >> str2num(A) ans = [] >> A='[1] [2] [2 3]' % without { } A = [1] [2] [2 3] >>str2num(A) ans = 1 2 2 3 ....but what I need is: A={[1] [2] [2 3]}. Hope there is a solution. Thank you! Grega
From: qooroo on 8 Sep 2009 10:33 editbox gives you a string, so you need to convert string to cell: doc cellstr so if your string from your editbox is A = '[1] [2] [2 3]' then you want A = cellstr(A) -qooroo
From: ImageAnalyst on 8 Sep 2009 11:43
On Sep 8, 10:33 am, "qooroo " <qooro...(a)gmailDOT.comREMOVECAPS> wrote: > editbox gives you a string, so you need to convert string to cell: > [snip] ------------------------------------------------------------------------------ That's what I thought. But it depends on what version you're using. In R2008b I was getting strings, but now I'm using R2009b(pre-release) and it's returning a cell array and so I need code like this: selectedRegionName = get(handles.edtRegion3, 'string'); % It seems that in version R2009b, they changed from returning a string (as in R2008b) to a cell array. if iscell(selectedRegionName) selectedRegionName = selectedRegionName{1}; end I'm not sure how it will end up in the release version of R2009b, nor do I know if it had already changed to cell arrays in R2009a since I have not used that version. It certainly would be easier if the edit fields just returned a simple string like you'd expect! |