From: RobuLAB on
I'm writing a GUI that serves to write data to a robot. The robot takes vectors of 11 elements. Once the user puts his vector in the edit text box, I check lenght and correct the vector if necessary. The problem is that when I try to set my edit text to display a vector, the whole box just vanishes.

My code is:

input = eval(get(hObject,'String'));
n=numel(input);

if n~=11
if n>11
%avertissement
%première ligne de l'avertissement
msgboxText{1} = 'Le vecteur est trop long';
%deuxième ligne de l'avertissement
msgboxText{2} = 'il serra reduit au format 1x11';

%création de l'avertissement
h = msgbox(msgboxText,'Faites attention au longeur du vecteur', 'warn');
input = input(1:11);
uiwait(h)
else
for x=n : 11
input = [input 0];
x=x+1;
end
end
set(hObject,'String',input);
end
guidata(hObject, handles);

My problem lies with the set-instruction.
Anyone has any ideas?

Thanks in advance!
From: RobuLAB on
mat2str seems to do exactly what I needed. So no need to reply to this one anymore


"RobuLAB " <amaury.ampe(a)etu.u-bordeaux1.fr> wrote in message <ht31k8$52k$1(a)fred.mathworks.com>...
> I'm writing a GUI that serves to write data to a robot. The robot takes vectors of 11 elements. Once the user puts his vector in the edit text box, I check lenght and correct the vector if necessary. The problem is that when I try to set my edit text to display a vector, the whole box just vanishes.
>
> My code is:
>
> input = eval(get(hObject,'String'));
> n=numel(input);
>
> if n~=11
> if n>11
> %avertissement
> %première ligne de l'avertissement
> msgboxText{1} = 'Le vecteur est trop long';
> %deuxième ligne de l'avertissement
> msgboxText{2} = 'il serra reduit au format 1x11';
>
> %création de l'avertissement
> h = msgbox(msgboxText,'Faites attention au longeur du vecteur', 'warn');
> input = input(1:11);
> uiwait(h)
> else
> for x=n : 11
> input = [input 0];
> x=x+1;
> end
> end
> set(hObject,'String',input);
> end
> guidata(hObject, handles);
>
> My problem lies with the set-instruction.
> Anyone has any ideas?
>
> Thanks in advance!