Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Line of code instead of "ans"

Asked by Martin on 7 Jun 2013

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

0 Comments

Martin

Tags

Products

No products are associated with this question.

3 Answers

Answer by Azzi Abdelmalek on 7 Jun 2013
Edited by Azzi Abdelmalek on 7 Jun 2013
Accepted answer
f=@(x,s,ii) [s sprintf('(%d)=',ii) num2str(x(ii))]
disp(f(A,'A',2))

0 Comments

Azzi Abdelmalek
Answer by Shashank Prasanna on 7 Jun 2013

Nothing I am aware of but you can terminate the code with a semicolon and then use the diary command to capture the commands.

http://www.mathworks.com/help/matlab/ref/diary.html

0 Comments

Shashank Prasanna
Answer by Martin on 7 Jun 2013

Thanks for your answers.

0 Comments

Martin

Contact us