1. 向量 : 一維的矩陣 , 可分為行向量及列向量 2. 矩陣 : 二維的陣列 , 一維向量為其特例
130 likes | 283 Views
1. 向量 : 一維的矩陣 , 可分為行向量及列向量 2. 矩陣 : 二維的陣列 , 一維向量為其特例 3. 陣列 : 為矩陣的延伸 , 可含有 n 維 , 一般二維矩陣及一維向量均為其特例. >> A=[1 2 3;2 3 4;4 5 6] >>C=A(2,:) A = C= 1 2 3 2 3 4
1. 向量 : 一維的矩陣 , 可分為行向量及列向量 2. 矩陣 : 二維的陣列 , 一維向量為其特例
E N D
Presentation Transcript
1.向量 : 一維的矩陣,可分為行向量及列向量 2.矩陣 : 二維的陣列,一維向量為其特例 3.陣列 : 為矩陣的延伸,可含有n維,一般二維矩陣及一維向量均為其特例
>> A=[1 2 3;2 3 4;4 5 6] >>C=A(2,:) A = C= 1 2 3 2 3 4 2 3 4 4 5 6 >> B=A(:,3) B = 3 4 6
指令 說明 zero(m,n) 產生維度為m×n,構成元素全為0的矩陣 ones(m,n) 產生維度為m×n,構成元素全為1的矩陣 eye(m,n) 產生維度為m×n,對角線的各元素全為1,其他各元素全為0的單位矩陣 pascal(m,n) 產生維度為m×n的Pascal矩陣 vander(m,n) 產生維度為m×n的Vandermonde矩陣 hilb(n) 產生維度為n×n的Hilbert矩陣 rand(m,n) 產生[0,1]均勻分佈的亂數矩陣,其維度為m×n randn(m,n) 產生μ=0,σ=1的正規分布亂數矩陣,其維度為m×n magic(n) 產生維度為n×n的魔方陣,其各直行、橫列及兩對角線的元素和都相等 特殊用途矩陣
特徵值與特徵向量若存在一向量v 與一常數λ,使得一方陣a 滿足Av = λ v ,稱λ 為特徵值,v 為特徵向量。
矩陣加法與減法大小相等的矩陣方可進行加減動作矩陣加法與減法大小相等的矩陣方可進行加減動作
矩陣冪次方項與指數A^P表矩陣A自乘P次,A^(-P)表矩陣A之反矩陣自乘P次,如a^(1/2),亦可以sqrtm(A)求之另.^有表示矩陣內同一位置元素自乘,如A.^(1/2),亦可以sqrt(A)求之矩陣冪次方項與指數A^P表矩陣A自乘P次,A^(-P)表矩陣A之反矩陣自乘P次,如a^(1/2),亦可以sqrtm(A)求之另.^有表示矩陣內同一位置元素自乘,如A.^(1/2),亦可以sqrt(A)求之
矩陣Y 的P 階範數 >> A=[1 2 3;4 5 6;7 8 9] A = 1 2 3 4 5 6 7 8 9 >> norm(A,2) ans = 16.8481
load C:\MATLAB6p5\work\grd_file\etopo5.txt % grd2xyz etopo5.grd > etopo5.txtt_x=etopo5(:,1);t_y=etopo5(:,2);t_z=etopo5(:,3);disp(sprintf('Range of longitude : %3.3f ~ %3.3f',min(t_x) ,max(t_x)));disp(sprintf('Range of latitude : %3.3f ~ %3.3f',min(t_y) ,max(t_y)));longitude_s=input('longitude_s=') ; longitude_e=input('longitude_e=') ; latitude_s=input('latitude_s=') ; latitude_e=input('latitude_e=') ;%120~130%20~50s=longitude_s; t=longitude_e; % set longitude rangeu=latitude_s; v=latitude_e; % set latitude ranged=find(t_x>=s & t_x<=t);e=find(t_y>=u & t_y<=v);f=intersect(d,e);etopo5_s=etopo5(f,:);etopo5_x=etopo5_s(:,1);etopo5_y=etopo5_s(:,2);etopo5_z=etopo5_s(:,3);
%%%%%%%%%%%%%%%%%%% interpolation %%%%%X=linspace(min(etopo5_x),max(etopo5_x),300);Y=linspace(min(etopo5_y),max(etopo5_y),300);[etopo5_X etopo5_Y]=meshgrid(X,Y);etopo5_Z=griddata(etopo5_x,etopo5_y,etopo5_z,etopo5_X,etopo5_Y);%%%%%%%%%%%%%%%%%%% plot %%%%%%%%%%%%%%figure(1);mesh(etopo5_X,etopo5_Y,etopo5_Z);axis('tight');figure(2);meshc(etopo5_X,etopo5_Y,etopo5_Z);axis('tight');figure(3);contour(etopo5_X,etopo5_Y,etopo5_Z);axis('tight');figure(4);contourf(etopo5_X,etopo5_Y,etopo5_Z);axis('tight');clear taiwan_* s t t_* d e f u v longitude_* latitude_* Taiwan