how to get disp('') to displace in one line instead of many
2 次查看(过去 30 天)
显示 更早的评论
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'
0 个评论
回答(1 个)
The Matlab Spot
2013-11-12
编辑:The Matlab Spot
2013-11-12
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!