- 輸入語句
?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