Please help if you can

Can you make matlab give answers in line with "ans = " , here is a photo(adress bellow text) of what i need , if this is possible please tell me how to do that. Thanks in advance http://imageshack.us/photo/my-images/28/42343019.jpg/

1 comentario

Oleg Komarov
Oleg Komarov el 28 de Feb. de 2012
Do you need that just for customization or for other specific reasons?

Iniciar sesión para comentar.

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 29 de Feb. de 2012

0 votos

It's not complicated to explain but it's quite annoying to implement. Have you tried my example in a comment to Sean's asnwer fprintf('\b %f',3)?
ans =
...
Is a message displayed (or printed) in the command window. To display something different from the standard behaviour requires you to use some specific functions that allow customization.
However, these functions (sprintf and fprintf) are not so flexible to adapt automatically to every situation while a consistent implementation of the customization would require to preserve the root formatting and to discriminate between variable types.
Thus you need to check the variable type and the root format, then you need to decline your customized formatting for each combination of the two above.

3 comentarios

Milos Ivankovic
Milos Ivankovic el 1 de Mzo. de 2012
fprintf('\b %f',3) 3.000000>> it gives an answer like this , i thought maybe there is a command to return the answer in the above row , like with a backslash "\" in fortran (Microsoft developer studio)
Oleg Komarov
Oleg Komarov el 2 de Mzo. de 2012
you can use sprintf or in fprintf('\b %f\n',3)
Milos Ivankovic
Milos Ivankovic el 5 de Mzo. de 2012
I like this idea , thank you so much

Iniciar sesión para comentar.

Más respuestas (3)

Sean de Wolski
Sean de Wolski el 28 de Feb. de 2012

0 votos

doc fprintf

1 comentario

Oleg Komarov
Oleg Komarov el 28 de Feb. de 2012
fprintf('\b %f',3)
This option obviously doesn't consider the get(0,'format') in use and the type of variable.
Thus, as Walter says, it is possible but would require quite some coding, which honestly IMO is in general not justified (and specifically in this case, since the OP did not motivate the use of it).

Iniciar sesión para comentar.

Walter Roberson
Walter Roberson el 28 de Feb. de 2012

0 votos

It is possible in theory: you can overwrite the method named "display". Which can be a big nuisance to do, but it is possible.
Milos Ivankovic
Milos Ivankovic el 29 de Feb. de 2012

0 votos

I wanted to brag to my professor :D but if it is too much trouble explaining then nevermind . Thank you :)

2 comentarios

Jan
Jan el 29 de Feb. de 2012
You can fake it by using "input('>> ', 's'); disp('ans = '); eval(S), input('>> ', 's');". I cannot check this currently, but it should look like a real command line output.
Milos Ivankovic
Milos Ivankovic el 1 de Mzo. de 2012
I like the idea to fake it , but it says undefined function or variable S , maybe i didnt quite understand , so if you could explain please

Iniciar sesión para comentar.

Categorías

Community Treasure Hunt

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

Start Hunting!

Translated by