displaying text before answer
88 次查看(过去 30 天)
显示 更早的评论
So I made a function on matlab but i want matlab to display 'the answer is' text and then the answer . How am I suppose to do that? I think I have to use disp code but I couldn't figure how.
0 个评论
回答(2 个)
Walter Roberson
2019-11-10
编辑:Walter Roberson
2019-11-10
Use fprintf() using a format that does not end in \n if you want to display something without going to the next line after.
0 个评论
Sarvesh Kale
2023-3-9
refer to the following code
x = 3.14 ;
fprintf("The value of pi is %f \n",x); % this will print the answer in your required format
I hope this helps
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!