Why 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
古いコメントを表示
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');
採用された回答
その他の回答 (1 件)
Geoff
2012 年 2 月 24 日
What value of s works, and what value of s breaks? Is s a string or an array of numbers?
You need to ensure that length(s) is less than 10 for this code to work. If s is not a string, you need to ensure that num2str(s(w)) is always the same length. You might consider using sprintf and specify padding etc in the format specifier.
eg
e = [e; sprintf('%2d. %c', w, s(w))]; % s is string
e = [e; sprintf('%2d. %-3d', w, s(w))]; % s is up to 3-digit int.
% etc....
Also, I would avoid the constant set and get calls, when you can do it with one set. Who knows - maybe that is what's causing problems:
e = [];
for w=1:length(s)
e = [e;num2str(w),'. ',num2str(s(w))];
end
set(handles.text12,'String',e);
Hope that helps.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!