Borrar filtros
Borrar filtros

how to get disp('') to displace in one line instead of many

2 visualizaciones (últimos 30 días)
Samious
Samious el 12 de Nov. de 2013
Editada: The Matlab Spot el 12 de Nov. de 2013
So If I have a function like
e.g.
function v=test(x) v=x+2; disp('The answer is'),disp(v),disp('hooray'); end
, when I put in x=1
I receive the value,
....................................
The answer is
1
hooray
...................................
ans
1
....................................
what do I need to do to get rid of the second part of the answer? (ans 1)
and how do I chance the first part so that the answer become 'The answer is 1 hooray'

Respuestas (1)

The Matlab Spot
The Matlab Spot el 12 de Nov. de 2013
Editada: The Matlab Spot el 12 de Nov. de 2013
Concat the strings...
function v=test(x)
v=x+2;
disp(['The answer is ',num2str(v),' hooray']);
end
At the command prompt...
>> v=test(1);
The answer is 3 hooray

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by