<email@example.com> wrote in message news:firstname.lastname@example.org... > I want to list the values of some selected variables in a given order. > The most easy way is type each variable one by one. > For examples, > a=1; > b=2; > c=3; > a > b > c > > In the command widows, it will show > a = > 1 > b = > 2 > c = > 3 > > Is it possible to make it look like > a = 1 > b = 2 > c = 3 > > I don't want the values showed in a new line. > the later is more readable for me.
If you object to the blank lines between the variables being displayed, then FORMAT COMPACT may be sufficient for your needs. If it isn't, doing this exactly as your code shows would not be possible without overloading how the display function works in general, which is a rather big hammer. If you are okay with calling a function to display your variables in this manner, it's much easier.
function showOneLine(variable) nameOfVariable = inputname(1); fprintf('%s = %s\n', nameOfVariable, mat2str(variable));
a = 1; showOneLine(a)
Add error checking (empty nameOfVariable, N-D arrays, etc.) to taste.