matlab的輸入輸出常見語句


https://blog.csdn.net/winone361/article/details/45457485



  • 輸入語句
  • 輸入數值

x=input('please input a number:')

please input a number:22

x = 22

輸入字符串

x=input('please input a string:','s')

please input a string:this is a string

x = this is a string

  • 輸出語句
  • 輸出顯示
  • 命令自由格式 (disp)

disp(23+454-29*4)

361

disp([11 22 33; 44 55 66; 77 88 99])

11 22 33

44 55 66

77 88 99

?disp('this is a string')

this is a string

      • 格式化輸出 (fprintf)。

 fprintf('The area is %8.5f\n', area) % 注意輸出格式前須有%符號,

%跳行符號須有\符號

The area is 12.56637 % 輸出值為8位數含5位小數

在這里你如果學過c語言就能很好的理解了。

    • 錯誤消息顯示命令

error('this is an error')

 this is an error


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM