x=-3.5:0.1:3.5;
y=x.^2-1;
plot(x,y,'--b')
x=-3:0.1:-1;
y=x.^2-1;
hold on
plot(x,y,'b','LineWidth',1.5)
axis([-3.5 3.5 -1.5 10])
line( [0 0], [-1.5 10], 'color', 'm');
line( [-3.5 3.5], [0 0], 'color', 'm');
line( [-1 -1], [-0.5 0.2], 'color', 'r');
line( [-3 -3], [-0.5 9], 'color', 'r');
gtext('(0,0)')
gtext('-3')
gtext('-1')
gtext('(-3,8)')
gtext('(0,-1)')
gtext('\fontname{Times New Roman}\fontsize{14}{\itf}\rm({\itx}) = {\itx}^2-1')
x=-4:0.1:-1;
y=x.^2-1;
%subplot(1,2,2),
figure, plot(x,y,'b','LineWidth',1.5)
hold on
x=0:0.1:10;
y=-sqrt(x+1);
plot(x,y,'g','LineWidth',1.5)
x=-4:0.1:10;
y=x;
plot(x,y,'--c')
hold off
axis([-4 10 -4 10])
line( [0 0], [-4 10], 'color', 'm');
line( [-4 10], [0 0], 'color', 'm');
line( [-1 -1], [-0.5 0.2], 'color', 'r');
line( [-3 -3], [-0.5 9], 'color', 'r');
line( [-0.5 0.2], [-1 -1], 'color', 'r');
line( [-0.5 9], [-3 -3], 'color', 'r');
gtext('(0,0)')
gtext('-3')
gtext('-1')
gtext('-1')
gtext('-3')
gtext('(-3,8)')
gtext('(-1,0)')
gtext('(0,-1)')
gtext('(8,-3)')
mystr = '$f(x) = x^2-1$';
h = text('string',mystr,'interpreter','latex',...
'fontsize',14,'units','norm','pos',[0.11 0.7]);
mystr = '$f^{-1}(x) = -\sqrt{x+1}$';
h = text('string',mystr,'interpreter','latex',...
'fontsize',14,'units','norm','pos',[0.63 0.16]);
2015年5月28日 星期四
2015年3月2日 星期一
15.基本陣列(矩陣)運算函數
>> A=magic(3); B=2*A;
>> det(A)
ans =
-360
>> expm(A)
ans =
1.0e+006 *
1.0898
1.0896 1.0897
1.0896 1.0897
1.0897
1.0896 1.0897
1.0897
>> A=magic(2)
A =
1 3
4 2
>> inv(A)
ans =
-0.2000 0.3000
0.4000 -0.1000
>> B=expm(A)
B =
63.6830 63.5476
84.7302 84.8655
>> logm(B)
ans =
1.0000 3.0000
4.0000 2.0000
>> pow2(B,A)
ans =
1.0e+003 *
0.1274 0.5084
1.3557 0.3395
>> sqrtm(A)
ans =
0.9583 + 0.8081i 0.9583 -
0.6061i
1.2778 - 0.8081i 1.2778 +
0.6061i
14.陣列(矩陣)處理函數
陣列(矩陣)處理函數
命令
|
功能
|
[A, B] 或
[A B]
|
將相同列數的A、B陣列合併成新的橫排陣列,此陣列的列數不變。
|
[A; B]
|
將相同行數的A、B陣列合併成新的縱排陣列,此陣列的行數不變。
|
cat(dim,
A, B)
|
依dim指定,將A、B陣列合併成新的陣列,A、B陣列的dim維度必須相同。dim為1, 2, ...分別表示row,
column, ...。
|
diag(A)
|
回傳陣列A的主對角元素之行向量。
|
diag(A, n)
|
回傳陣列A的第n個對角元素之行向量。
|
diag(x)
|
建構一個以x為內容的對角矩陣,除主對角元素以外均為0。
|
flipdim(A, dim)
|
將陣列A以dim維度翻轉。dim為1,
2, ...分別表示row, column, ...。
|
fliplr(A)
|
將陣列A的元素左右翻轉。
|
flipud(A)
|
將陣列A的元素上下翻轉。
|
repmat(A,[m, n, ..., r])
|
將陣列A的元素沿第一維度重複m次;沿第二維度重複n次,以此類推。
|
repmat(A, m, n)
|
將陣列A的元素沿第一維度重複m次;沿第二維度重複n次。
|
reshape(A, m, n)
|
將陣列A的元素重新建立一個大小為m×n的陣列。元素各數不可增減。
|
rot90(A)
|
將陣列A的元素逆時針旋轉90度。
|
rot90(A, n)
|
將陣列A的元素逆時針旋轉90×n度。
|
tril(A)
|
回傳陣列A的下三角陣列。
|
tril(A, n)
|
回傳陣列A的第n個下三角陣列。
|
triu(A)
|
回傳陣列A的上三角陣列。
|
triu(A, n)
|
回傳陣列A的第n個上三角陣列。
|
wshift(type, x, p)
|
列(行)向量x之循環位移。
type可為1、'1'、'1d'、'1D',p必須為整數,p>0為向左(上)循環位移;p<0為向右(下)循環位移;p=0則維持不變。
|
wshift(type, A, p)
|
陣列A之循環位移,type可為2、'2'、'2d'、'2D',p必須為整數的列向量,p(1)控制行循環位移;p(2)控制列循環位移。p(1)>0為向上循環位移;p(1)<0為向下循環位移;p(1)=0則維持不變;p(2)>0為向左循環位移;p(2)<0為向右循環位移;p(2)=0則維持不變。
|
>> A=magic(3); B=2*A;>> C=[A; B]C =8 1 63 5 74 9 216 2 126 10 148 18 4>> D=[A B]D =8 1 6 16 2 123 5 7 6 10 144 9 2 8 18 4>> E=cat(2,A,B)E =8 1 6 16 2 123 5 7 6 10 144 9 2 8 18 4>> diag(E)ans =852>> x=diag(E)x =852>> diag(x)ans =8 0 00 5 00 0 2>> diag(E,-1)ans =39>> diag(E,3)ans =16104>> flipdim(A,1)ans =4 9 23 5 78 1 6>> fliplr(A)ans =6 1 87 5 32 9 4>> flipud(A)ans =4 9 23 5 78 1 6>> repmat(A,[2, 3, 1])ans =8 1 6 8 1 6 8 1 63 5 7 3 5 7 3 5 74 9 2 4 9 2 4 9 28 1 6 8 1 6 8 1 63 5 7 3 5 7 3 5 74 9 2 4 9 2 4 9 2>> repmat(A,2,3)ans =8 1 6 8 1 6 8 1 63 5 7 3 5 7 3 5 74 9 2 4 9 2 4 9 28 1 6 8 1 6 8 1 63 5 7 3 5 7 3 5 74 9 2 4 9 2 4 9 2>> reshape(A, 1, 9)ans =8 3 4 1 5 9 6 7 2>> reshape(A(3:6), 2, 2) %增加限制元素條件ans =4 51 9>> rot90(A)ans =6 7 21 5 98 3 4>> rot90(A,3)ans =4 3 89 5 12 7 6>> tril(A)ans =8 0 03 5 04 9 2>> tril(A,-1)ans =0 0 03 0 04 9 0>> triu(A)ans =8 1 60 5 70 0 2>> triu(A,1)ans =0 1 60 0 70 0 0>> wshift('1d', x, 1)ans =528>> wshift('1d', x, -1)ans =285>> wshift('2d', A, [1 -1])ans =7 3 52 4 96 8 1>> wshift('2d', A, [-1 0])ans =4 9 28 1 63 5 7
2014年11月20日 星期四
繪圖之水平座標與垂直座標刻度設定
Example:
n = [-100:100];
x = cos(0.1*pi*n);
Hx = stem(n,x,'r--','filled');
set(Hx,'markersize',2);
axis([-110, 110,-2,2]);
xtick = [-100:18:100];
ytick = [-2:0.5:2];
set(gca,'XTickMode','manual','XTick',xtick);
set(gca,'YTickMode','manual','YTick',ytick);
xlabel('n','FontSize',10);
ylabel('x(n)','FontSize',10);
其中水平座標刻度設定
xtick = [刻度由此開始:刻度間隔:刻度結束]
垂直座標刻度設定亦同
ytick = [刻度由此開始:刻度間隔:刻度結束]
n = [-100:100];
x = cos(0.1*pi*n);
Hx = stem(n,x,'r--','filled');
set(Hx,'markersize',2);
axis([-110, 110,-2,2]);
xtick = [-100:18:100];
ytick = [-2:0.5:2];
set(gca,'XTickMode','manual','XTick',xtick);
set(gca,'YTickMode','manual','YTick',ytick);
xlabel('n','FontSize',10);
ylabel('x(n)','FontSize',10);
其中水平座標刻度設定
xtick = [刻度由此開始:刻度間隔:刻度結束]
垂直座標刻度設定亦同
ytick = [刻度由此開始:刻度間隔:刻度結束]
2014年10月25日 星期六
會用這個軟體,將能提高你進Google工作的機率
Google的資深副總裁Jonathan Rosenberg-----會用這個軟體,將能提高你進Google工作的機率如果你想要在Google工作,最好確定你要會用「MatLab」這個軟體。
http://www.techbang.com/posts/20491-will-use-this-program-you-work-in-googles-chances-will-increase
http://www.techbang.com/posts/20491-will-use-this-program-you-work-in-googles-chances-will-increase
2014年9月3日 星期三
更改繪圖axis字型
Example
n = [0:20]; x = [(n-3) == 0];
hd = stem(n,x,'k');
axis([0,20,min(x),max(x)]);
set(get(hd,'Parent'),'FontName','times new roman')
Results
原始圖(字型為Helvetica)
n = [0:20]; x = [(n-3) == 0];
hd = stem(n,x,'k');
axis([0,20,min(x),max(x)]);
set(get(hd,'Parent'),'FontName','times new roman')
Results
原始圖(字型為Helvetica)
更改後(字型為times new roman)
觀察繪圖區內的屬性
Example:
n = [0:20]; x = [(n-3) == 0];
hd = stem(n,x,'k');
axis([0,20,min(x),max(x)]);
get(get(hd,'Parent'))
Results:
ActivePositionProperty = outerposition
ALim = [0 1]
ALimMode = auto
AmbientLightColor = [1 1 1]
Box = on
CameraPosition = [10 0.5 17.3205]
CameraPositionMode = auto
CameraTarget = [10 0.5 0]
CameraTargetMode = auto
CameraUpVector = [0 1 0]
CameraUpVectorMode = auto
CameraViewAngle = [6.60861]
CameraViewAngleMode = auto
CLim = [0 1]
CLimMode = auto
Color = [1 1 1]
CurrentPoint = [ (2 by 3) double array]
ColorOrder = [ (7 by 3) double array]
DataAspectRatio = [20 1 2]
DataAspectRatioMode = auto
DrawMode = normal
FontAngle = normal
FontName = Helvetica
FontSize = [10]
FontUnits = points
FontWeight = normal
GridLineStyle = :
Layer = bottom
LineStyleOrder = -
LineWidth = [0.5]
MinorGridLineStyle = :
NextPlot = replace
OuterPosition = [ (1 by 4) double array]
PlotBoxAspectRatio = [1 1 1]
PlotBoxAspectRatioMode = auto
Projection = orthographic
Position = [ (1 by 4) double array]
TickLength = [0.01 0.025]
TickDir = in
TickDirMode = auto
TightInset = [ (1 by 4) double array]
Title = [182.015]
Units = normalized
View = [0 90]
XColor = [0 0 0]
XDir = normal
XGrid = off
XLabel = [183.015]
XAxisLocation = bottom
XLim = [0 20]
XLimMode = manual
XMinorGrid = off
XMinorTick = off
XScale = linear
XTick = [ (1 by 11) double array]
XTickLabel = [ (11 by 2) char array]
XTickLabelMode = auto
XTickMode = auto
YColor = [0 0 0]
YDir = normal
YGrid = off
YLabel = [184.015]
YAxisLocation = left
YLim = [0 1]
YLimMode = manual
YMinorGrid = off
YMinorTick = off
YScale = linear
YTick = [ (1 by 11) double array]
YTickLabel = [ (11 by 3) char array]
YTickLabelMode = auto
YTickMode = auto
ZColor = [0 0 0]
ZDir = normal
ZGrid = off
ZLabel = [185.015]
ZLim = [-1 1]
ZLimMode = auto
ZMinorGrid = off
ZMinorTick = off
ZScale = linear
ZTick = [-1 0 1]
ZTickLabel =
ZTickLabelMode = auto
ZTickMode = auto
BeingDeleted = off
ButtonDownFcn =
Children = [ (2 by 1) double array]
Clipping = on
CreateFcn =
DeleteFcn =
BusyAction = queue
HandleVisibility = on
HitTest = on
Interruptible = on
Parent = [1]
Selected = off
SelectionHighlight = on
Tag =
Type = axes
UIContextMenu = []
UserData = []
Visible = on
n = [0:20]; x = [(n-3) == 0];
hd = stem(n,x,'k');
axis([0,20,min(x),max(x)]);
get(get(hd,'Parent'))
Results:
ActivePositionProperty = outerposition
ALim = [0 1]
ALimMode = auto
AmbientLightColor = [1 1 1]
Box = on
CameraPosition = [10 0.5 17.3205]
CameraPositionMode = auto
CameraTarget = [10 0.5 0]
CameraTargetMode = auto
CameraUpVector = [0 1 0]
CameraUpVectorMode = auto
CameraViewAngle = [6.60861]
CameraViewAngleMode = auto
CLim = [0 1]
CLimMode = auto
Color = [1 1 1]
CurrentPoint = [ (2 by 3) double array]
ColorOrder = [ (7 by 3) double array]
DataAspectRatio = [20 1 2]
DataAspectRatioMode = auto
DrawMode = normal
FontAngle = normal
FontName = Helvetica
FontSize = [10]
FontUnits = points
FontWeight = normal
GridLineStyle = :
Layer = bottom
LineStyleOrder = -
LineWidth = [0.5]
MinorGridLineStyle = :
NextPlot = replace
OuterPosition = [ (1 by 4) double array]
PlotBoxAspectRatio = [1 1 1]
PlotBoxAspectRatioMode = auto
Projection = orthographic
Position = [ (1 by 4) double array]
TickLength = [0.01 0.025]
TickDir = in
TickDirMode = auto
TightInset = [ (1 by 4) double array]
Title = [182.015]
Units = normalized
View = [0 90]
XColor = [0 0 0]
XDir = normal
XGrid = off
XLabel = [183.015]
XAxisLocation = bottom
XLim = [0 20]
XLimMode = manual
XMinorGrid = off
XMinorTick = off
XScale = linear
XTick = [ (1 by 11) double array]
XTickLabel = [ (11 by 2) char array]
XTickLabelMode = auto
XTickMode = auto
YColor = [0 0 0]
YDir = normal
YGrid = off
YLabel = [184.015]
YAxisLocation = left
YLim = [0 1]
YLimMode = manual
YMinorGrid = off
YMinorTick = off
YScale = linear
YTick = [ (1 by 11) double array]
YTickLabel = [ (11 by 3) char array]
YTickLabelMode = auto
YTickMode = auto
ZColor = [0 0 0]
ZDir = normal
ZGrid = off
ZLabel = [185.015]
ZLim = [-1 1]
ZLimMode = auto
ZMinorGrid = off
ZMinorTick = off
ZScale = linear
ZTick = [-1 0 1]
ZTickLabel =
ZTickLabelMode = auto
ZTickMode = auto
BeingDeleted = off
ButtonDownFcn =
Children = [ (2 by 1) double array]
Clipping = on
CreateFcn =
DeleteFcn =
BusyAction = queue
HandleVisibility = on
HitTest = on
Interruptible = on
Parent = [1]
Selected = off
SelectionHighlight = on
Tag =
Type = axes
UIContextMenu = []
UserData = []
Visible = on
訂閱:
文章 (Atom)





