matlab輸入輸出語句(input、disp、fprintf)


  • 輸入語句
輸入數值
?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.5f 輸出值為8位數含5位小數

 

錯誤消息顯示命令
?error('this is an error')
??? this is an error

 

 


免責聲明!

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



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