一個簡單的例子
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 程序說明:第一個M程序庐船,做簡單的數(shù)值計算舔庶、輸出、畫圖
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 數(shù)值計算压汪,語句結(jié)束不加分號,可以在命令窗口查看結(jié)果
value = sin(pi/4)+cos(1)+log(2)
% 在命令窗口輸出文本
disp('Hello World');
% 畫一個正弦函數(shù)
t = 0:0.5:2*pi;
y = sin(t);
plot(t,y,'-ko','MarkerFace','g')
一、數(shù)據(jù)類型和數(shù)組
MATLAB中共有15種基本的數(shù)據(jù)類型
plot()函數(shù)中LineSpec可選的字符列表
plot()函數(shù)中PropertyName可選的字符列表