Display answer

Suppose i have three part in a program. I can see three display at a time when i run the program.
If I want to see the result individually, what I have to do (without blocking semicolon or keeping % before display or fprintf command)?
suppose,
a=5; disp(5) b=6; disp(b) c=55; disp(c)
I want to see only the result of b Pls help me somebody

답변 (2개)

Paulo Silva
Paulo Silva 2011년 4월 5일

0 개 추천

b
Walter Roberson
Walter Roberson 2011년 4월 5일

0 개 추천

evalc() the program and use text processing techniques to locate the display of "b" and print it out.

댓글 수: 2

Mohammad Yunus Ali
Mohammad Yunus Ali 2011년 4월 5일
%%
a=5; disp(5)
%%
b=6; disp(b)
%%
c=55; disp(c)
Pls use this program. I want to see the result of "b" part only. I will click on b part and run the program.
Walter Roberson
Walter Roberson 2011년 4월 5일
t = textscan(evalc(sprintf('%s\n', '%%', 'a=5; disp(5)', '%%', 'b=6; disp(b)', '%%', 'c=55; disp(c)')),'%s');
The b part is then
t{1}{2}
However, considering you have put the %% there, possibly the answer you are really looking for is this:
Click on the part you want executed. Right-click and select "execute cell"

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

질문:

2011년 4월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by