本篇內容集合了MATLAB中的基本操作、數據存儲與計算、數據的直線與曲線擬合與畫圖、for-if-while語句的使用方法對一般matlab的操作進行了基本和詳細的應用舉例,非常適合初學者進行matlab學習快速掌握。下面分四個模塊分別進行講述:
========================BasicOperations========================
>> A=rand(3,2)
A =
0.8147 0.9134
0.9058 0.6324
0.1270 0.0975
>> A=[1 2;3 4;5 6]
A =
1 2
3 4
5 6
>> A(3,2)
ans =
6
>> A(2,:)
ans =
3 4
>> A([1 3],:) %select the 1st and 3rd row
ans =
1 2
5 6
>> save test.mat A
>> save testtext.txt A –ascii
>> A(:,2)=[10,11,12]
A =
1 10
3 11
5 12
>> A=[A,[101;102;103]]%append another column vector
A =
1 10 101
3 11 102
5 12 103
>> A(:)%put all elements of A into a single vector
ans =
1
3
5
10
11
12
101
102
103
B=[11,12;13,14;15,16]
B =
11 12
13 14
15 16
>> C=[A B]
C =
1 10 101 11 12
3 11 102 13 14
5 12 103 15 16
A=[1 2;3 4;5 6]
A =
1 2
3 4
5 6
>> C=[A;B]
C =
1 2
3 4
5 6
11 12
13 14
15 16