MATLAB: And how can i fix the vert cat error in this code? It works fine with a 3 len string but over that i get a vert cat error

vertcat

function PeaksFlare_Callback(hObject, eventdata, handles)
global s;
set(handles.text12,'String','');
for w=1:length(s)
e=get(handles.text12,'String');
e=[e;num2str(w),'. ',num2str(s(w))];
set(handles.text12,'String',e);
end
set(handles.text11,'visible','on');
set(handles.text12,'visible','on');

Best Answer

You set "e" as a string, and then you try
e=[e;num2str(w),'. ',num2str(s(w))];
This tries to put (num2str(w),'. ',num2str(s(w))) as a new row in "e". How long is that string going to come out? If it doesn't happen to come out as exactly the same number of columns as "e" already is, you are going to have a problem.
You can change the code as
for w=1:length(s)
e = cellstr( get(handles.text12,'String') );
e{end+1} = [num2str(w),'. ',num2str(s(w))];
set(handles.text12,'String',e);
end