Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

replace the command 'set' in GUI

조회 수: 2 (최근 30일)
Jwana
Jwana 2012년 12월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello...
how can I use the command 'set' in the GUI in matlab that it can keep the previous answer and not to replace it with the new one. like for example, when I use a for loop and get more than one output, in the normal matlab code it will keep all outputs and print it in the screen as the following:
for i=2:length(contextt)
if ~isequal(co1,co2)
if strcmp(q,pc) || ~ismember(tt1(length(tt1)),tt3)
fprintf('RKC = { %s , %s }\n',pc,cc)
set(textA,'string',['RKC = {',pc ,',', cc,'}']);
end
end
end
the result will be the follwoing:
answer = { a0.b0.d6 , a0.c0 }
answer = { a0.c0 , a0.c0.d5 }
answer = { a0.c1.b2.d13 , a0.c1.c3 }
but in the GUI version, when I type:
set(textA,'string',['answer = {',pc ,',', cc,'}']);
it will give me only the last answer means that it updates the answer every time the for loop begins:
answer={a0.d2.c2 , a0.d2.c2.d10}
so is there any command in GUI that can keep answers and put each answer in one line like the fprintf does..
Thank you

답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 22일
There is no set() that will keep the existing information and add more to it. You need to get() the previous information, add the new information to it, and set() that as the new data.
  댓글 수: 9
Image Analyst
Image Analyst 2012년 12월 22일
Try this:
str2=sprintf('RKC = { %15s %22s}',str1{1}, str1{2});
Use whatever field widths you want.
Jwana
Jwana 2012년 12월 22일
@ Image Analyst...it works with str=sprintf('RKC = { %22s , %22s }',pc, cc); !! thank you :)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by