Line of code instead of "ans"

2 vues (au cours des 30 derniers jours)
Martin
Martin le 7 Juin 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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 7 Juin 2013
Modifié(e) : Azzi Abdelmalek le 7 Juin 2013
f=@(x,s,ii) [s sprintf('(%d)=',ii) num2str(x(ii))]
disp(f(A,'A',2))

Plus de réponses (2)

Shashank Prasanna
Shashank Prasanna le 7 Juin 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.

Martin
Martin le 7 Juin 2013
Thanks for your answers.

Catégories

En savoir plus sur Language Support dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by