From: qooroo on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <1d7369c1-bc71-49bb-82bf-34f76b030eea(a)y9g2000yqn.googlegroups.com>...
> ------------------------------------------------------------------------------
> 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!

that's odd. surely the behaviour of

get(hObject,'String')

under editbox callback is the same, I mean it can't give you something other than a string...

-qooroo
From: ImageAnalyst on
On Sep 9, 3:17 am, "qooroo " <qooro...(a)gmailDOT.comREMOVECAPS> wrote:
> ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <1d7369c1-bc71-49bb-82bf-34f76b030...(a)y9g2000yqn.googlegroups.com>...
> > ---------------------------------------------------------------------------­---
> > 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!
>
> that's odd. surely the behaviour of
>
> get(hObject,'String')
>
> under editbox callback is the same, I mean it can't give you something other than a string...
>
> -qooroo-
------------------------------------------------------------------------------------------------------------------------------------------------------------

qooroo:

You'd think. But no. Here's my code from R2009b prerelease to test
what you suggested:


%=====================================================================
function edtRegion1_Callback(hObject, eventdata, handles)
% hObject handle to edtRegion1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edtRegion1 as text
% str2double(get(hObject,'String')) returns contents of
edtRegion1 as a double
strRegionName = get(hObject,'String');
caRegionName = get(handles.edtRegion1, 'string');

When I check strRegionName and caRegionName in the workspace, guess
what?
It says they're both 1 by 1 cell arrays.
-ImageAnalyst
From: qooroo on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <ed3aa391-7ff3-4709-9c8b-7194af86a261(a)r9g2000yqa.googlegroups.com>...
> You'd think. But no. Here's my code from R2009b prerelease to test
> what you suggested:
>
>
> %=====================================================================
> function edtRegion1_Callback(hObject, eventdata, handles)
> % hObject handle to edtRegion1 (see GCBO)
> % eventdata reserved - to be defined in a future version of MATLAB
> % handles structure with handles and user data (see GUIDATA)
> % Hints: get(hObject,'String') returns contents of edtRegion1 as text
> % str2double(get(hObject,'String')) returns contents of
> edtRegion1 as a double
> strRegionName = get(hObject,'String');
> caRegionName = get(handles.edtRegion1, 'string');
>
> When I check strRegionName and caRegionName in the workspace, guess
> what?
> It says they're both 1 by 1 cell arrays.
> -ImageAnalyst


that's terrifying. and would make quite a few of my guis bad. just for example string concatenation,

strRegionName = get(hObject,'String');
strFull = [strRegionName '_please let me be one string']

would give a 1x2 cell, not a complete string. surely it's a bug?

-qooroo
From: Christopher Hummersone on
[snip]
>
> strRegionName = get(hObject,'String');
> strFull = [strRegionName '_please let me be one string']
>
> would give a 1x2 cell, not a complete string. surely it's a bug?
>
> -qooroo

Nope, concatenating two char arrays with brackets has always produced a larger char array.

See http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/matlab_prog/f10-60825.html&http://www.mathworks.com/cgi-bin/texis/webinator/search/

Chris
From: ImageAnalyst on
On Sep 9, 10:44 am, "qooroo " <qooro...(a)gmailDOT.comREMOVECAPS> wrote:
> ImageAnalyst <imageanal...(a)mailinator.com> wrote in message <ed3aa391-7ff3-4709-9c8b-7194af86a...(a)r9g2000yqa.googlegroups.com>...
> > You'd think.  But no.  Here's my code from R2009b prerelease to test
> > what you suggested:
>
> > %=====================================================================
> > function edtRegion1_Callback(hObject, eventdata, handles)
> > % hObject    handle to edtRegion1 (see GCBO)
> > % eventdata  reserved - to be defined in a future version of MATLAB
> > % handles    structure with handles and user data (see GUIDATA)
> > % Hints: get(hObject,'String') returns contents of edtRegion1 as text
> > %        str2double(get(hObject,'String')) returns contents of
> > edtRegion1 as a double
> >    strRegionName = get(hObject,'String');
> >    caRegionName = get(handles.edtRegion1, 'string');
>
> > When I check strRegionName and caRegionName in the workspace, guess
> > what?
> > It says they're both 1 by 1 cell arrays.
> > -ImageAnalyst
>
> that's terrifying. and would make quite a few of my guis bad. just for example string concatenation,
>
> strRegionName = get(hObject,'String');
> strFull = [strRegionName '_please let me be one string']
>
> would give a 1x2 cell, not a complete string. surely it's a bug?
>
> -qooroo-

------------------------------------------------------------------------------------------------------------------------------------------
Even the Mathworks tech support folks were surprised. They're the
ones who told me to use iscell() workaround to check so that it would
work for any version. I'll send it in as a bug report. But with my
license lasting only about 20 days, the new release is about to come
out within that time I imagine, so I'm not sure it will make it in if
they don't already know about it. I notified them of another bug a
couple of weeks ago and they said that they couldn't fix it in time.

What you said was right (I think Chris misunderstood). I ran your
code in R2009b and verfied that it is, in fact, a 1 by 2 cell and you
do not have one long string. I am not sure why they decided to make
this change. Unless they fix this, you'll be implementing the
workaround like I did to have your old m-files run in the new
version. Maybe Steve Lord has some inside info on this????
-ImageAnalyst
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: cognitive radio
Next: Combining histogram and plot