How do i print '^' in sprintf?

2 次查看(过去 30 天)
Kaelan Wade
Kaelan Wade 2017-5-19
回答: KSSV 2017-5-19
  • Just say
  • a = 2
  • b = 3
  • and i wanted to print " a*x^b " using sprintf
  • why is it when in use sprintf('%.2f*x^%.2f',a,b)
  • or even sprintf(%.2f*x%s%.2f',a,'^',b)
  • matlab prints 2.00*x3.00
  • How would I print " 2.00*x^3.00 " ?

回答(1 个)

KSSV
KSSV 2017-5-19
a = 2 ;
b = 3 ;
sprintf('%d*x^%d',a,b)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by