Line of code instead of "ans"

조회 수: 3 (최근 30일)
Martin
Martin 2013년 6월 7일
Hello,
I begin by an example.
A = [2 4]; A(1)
I'd like to know if there's a setting in the Matlab Preferences which returns
A(1) = 2
instead of
ans = 2
I know that I can write something like
fprintf('A(1)', num2str(A(1)));
but it's long to do for every variables I want to display.
Thanks,
Martin

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 7일
편집: Azzi Abdelmalek 2013년 6월 7일
f=@(x,s,ii) [s sprintf('(%d)=',ii) num2str(x(ii))]
disp(f(A,'A',2))

추가 답변 (2개)

Shashank Prasanna
Shashank Prasanna 2013년 6월 7일
Nothing I am aware of but you can terminate the code with a semicolon and then use the diary command to capture the commands.

Martin
Martin 2013년 6월 7일
Thanks for your answers.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by