Getting For loop Output On GUI

1 次查看(过去 30 天)
i have this loop code and on matlab i get the out i want but on GUI its not working.....
for nn=1:a
stri=character(nn);
stri=strcat(stri,':');
stri=strcat(stri,num2str(probabilities(nn)));
stri=strcat(stri,':');
stri=strcat(stri,num2str(codewords{nn}(length(codewords{nn}):-1:1)))
end
what i get on matlab:
:.234:0 1
A:.254:1101
C:.123:10001
D:.112:1001100
F:.234:0001110
but my problem is when i put it on GUI its keep getting me the last stri GUI out Put:
F:.234:0001110
which the last one i have on the stri
and im using this codes to get it on GUI :
nnn=num2str(stri);
set(handles.EditBox,'string',nnn)
i want to get every step that loop doing on GUI not only the final results
any help will be so grateful.....
Thank you

采纳的回答

Walter Roberson
Walter Roberson 2012-12-25
outstrings = cell(a, 1);
for nn=1:a
stri=character(nn);
stri=strcat(stri,':');
stri=strcat(stri,num2str(probabilities(nn)));
stri=strcat(stri,':');
stri=strcat(stri,num2str(codewords{nn}(length(codewords{nn}):-1:1)));
outstrings{nn} = stri;
end
set(handles.Editbox, 'String', outstrings);

更多回答(2 个)

mohamed
mohamed 2012-12-25
thank you Walter you are really the best just because you care enough to look and answer :)
i tried to put ur codes but when i did the editbox i made in the GUI gone :S and on matlab i got this
Warning: Single line Edit Controls can not have multi-line text
Warning: Single line Edit Controls can not have multi-line text
Warning: Single line Edit Controls can not have multi-line text
>>
:S thank you again
  2 个评论
ngassa
ngassa 2013-3-26
HI Roberson. i am new in matlab , and i habe a problem, can you help me please i have this loop code and on matlab i get the out i want but on GUI its not working.... for i= 1:n for j = 1:k(i) output (j) = d(i,j); end disp(output) end i want any value in a box, for example , when n = 8 , i have 8 boxes , and i want one value in one box. thank you

请先登录,再进行评论。


mohamed
mohamed 2012-12-25
OMG you are the best walter thank you so much and im sorry for bothering its working :D .......
thank you again.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by