永成的學習部落格

這裡會記錄永成學習的一部分

0%

勤益(二下)課程-上課筆記 專業軟體應用及實習

這裡記錄著我在課堂中的學習

⬇⬇⬇文章開始⬇⬇⬇

開始

  1. MATLAB
  2. Office
    1. Word
    2. Powerpoint
    3. Excel
  3. SPSS(統計軟體)
  4. Octare
  5. Chrome (Google Search Console)
  6. Python、C、C++ 等…

2020-03-13

Part 1

1
2
3
4
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
x=[1 3 5 7 9 6 45 4];
plot(x) % 基本繪圖
mean(x) % 平均值

Part 2

1
2
3
4
5
6
7
8
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=0:0.01:1;
x=2*sin(2*pi*t);
y=2*cos(2*pi*t);

plot(x,"r") % 畫x值為r(紅色red),直線為預設繪圖圖形。
hold on % 就不會清除前面的圖,而是重複畫上去。
plot(y,"*b") % 畫y值為b(藍色blue),【*】為繪圖圖形。

Part 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=0:0.0005:0.15;
x=2*sin(2*pi*t);
y=2*cos(2*pi*t);
z=2*tan(1*pi*t);

subplot(221) % 在平舖位置創建軸1
plot(x,"r")
subplot(222) % 在平舖位置創建軸2
plot(y,"*b")
subplot(223) % 在平舖位置創建軸3
plot(z,"og")
subplot(224) % 在平舖位置創建軸4
plot(z,"s")

Part 4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=0:0.0005:0.15;
x=2*sin(2*pi*t);
y=2*cos(2*pi*t);
z=2*tan(1*pi*t);

subplot(331) % 在平舖位置創建軸1
plot(x,"r")
subplot(332) % 在平舖位置創建軸2
plot(y,"r")
subplot(333) % 在平舖位置創建軸3
plot(z,"r")
subplot(334) % 在平舖位置創建軸4
plot(x,"og")
subplot(335) % 在平舖位置創建軸5
plot(y,"og")
subplot(336) % 在平舖位置創建軸6
plot(z,"og")
subplot(337) % 在平舖位置創建軸7
plot(x,"s")
subplot(338) % 在平舖位置創建軸8
plot(y,"s")
subplot(339) % 在平舖位置創建軸9
plot(z,"s")

Part 5

ezplot()函數與fplot()函數一樣,不需要繪圖數據陣列,只要設定一個描述函數的字串,就可運用ezplot()函數繪出指定的函數圖形。
ezplot()函數使用上比fplot()函數更為簡單。
 
ezplot()函數的命令格式如下:

ezplot(‘fun’, [xmin xmax ymin ymax], fig)

  • fun為函數的字串;
  • [xmin xmax ymin ymax]為顯示繪圖範圍向量,其中範圍向量可以省略,其預設值為-2pi~2pi之間的範圍;
  • fig為指定繪圖視窗編號
  • ezplot()函數不支援繪圖控制碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=0:0.0005:0.15;
x=2*sin(2*pi*t);
y=2*cos(2*pi*t);
z=2*tan(1*pi*t);

subplot(331) % 在平舖位置創建軸1
ezplot('17*x^2-16*abs(x)*y+17*y^2-225')
subplot(332) % 在平舖位置創建軸2
plot(y,"r")
subplot(333) % 在平舖位置創建軸3
plot(z,"r")
subplot(334) % 在平舖位置創建軸4
plot(x,"og")
subplot(335) % 在平舖位置創建軸5
plot(y,"og")
subplot(336) % 在平舖位置創建軸6
plot(z,"og")
subplot(337) % 在平舖位置創建軸7
plot(x,"s")
subplot(338) % 在平舖位置創建軸8
plot(y,"s")
subplot(339) % 在平舖位置創建軸9
ezplot('17*x^2-16*abs(x)*y+17*y^2-225')

Part 6

1
2
3
4
5
6
7
clc;clear;close all;   % 清除command window % 清除Workkspace % 關閉所有Figure的窗口

% 25個圖
for i=1:25
subplot(5,5,i) % 在平舖位置創建軸 5*5=25個
ezplot('17*x^2-16*abs(x)*y+17*y^2-225') %(不推薦)易於使用的功能繪圖儀
end

Part 7

1
2
3
4
5
6
7
8
9
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=0.25:0.001:0.75;
y=2*cos(2*pi*t);

figure, % 創建一個新的圖形窗口
bar(t,y) % 條形圖指令

figure, % 創建一個新的圖形窗口
plot(t,y, 'LineWidth',150) % 'LineWidth'程式指令[線的寬度];'150'為寬度大小[自定義大小]

Part 8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t = 1;
st = 1;
ct = 1;
plot3(t,st,ct,'o' ,'MarkerSize',30) % 3-D點或線圖,'MarkerSize'點標之大小(點數)
hold on % 就不會清除前面的圖,而是重複畫上去。
a = 80;
b = 70;
c = 60;
plot3(a,b,c,'o' ,'MarkerSize',30) % 3-D點或線圖,'MarkerSize'點標之大小(點數)

r = 30;
f = 40;
v = 50;
plot3(r,f,v,'o' ,'MarkerSize',30) % 3-D點或線圖,'MarkerSize'點標之大小(點數)

x = [a r t];
y = [b f st];
z = [c v ct];
plot3(x,y,z, '-.','MarkerSize',70) % 3-D點或線圖,'MarkerSize'點標之大小(點數)

2020-03-20

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
t=1:1000;
y=rand(1,1000).*500+t;
figure, % 創建一個新的圖形窗口
plot(t,y)

x=1001;
y=0.99973*x+256.67;
hold on % 就不會清除前面的圖,而是重複畫上去。
plot(x,y,'or')
x/y==2;
plot(x,y,'-.')

Part 2

1
2
3
4
5
6
7
8
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
A=[1 -2 3
-1 3 0
2 -5 5];
B=[9
-4
17];
X=inv(A)*B
1
2
3
4
X =
1
-1
2

Part 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
%
% curve test
%
clc;clear;close all; % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
a=[ 0.1 1
0.2 1.1
0.3 1.2
0.4 1.3
0.5 1.1
0.6 0.9
0.7 0.7
0.8 1.0
0.9 1.2
1 1.3];
plot(a(:,1),a(:,2),'*')
axis([0.1 1 0.5 1.5]); % 設置軸限制和縱橫比
pause % 暫時停止執行MATLAB
%
p=polyfit(a(:,1),a(:,2),4); % 多項式曲線擬合
fprintf('order of polynomial is 4')
p
t=0.1:0.001:0.95;
nev=polyval(p,t); % 多項式評估
plot(t,nev,a(:,1),a(:,2),'*')
axis([0 1.1 0.6 1.4]); % 設置軸限制和縱橫比
grid % 顯示或隱藏軸網格線
title('order of polynomial is 4')
xlabel('input data')
ylabel('output data')
pause % 暫時停止執行MATLAB
%
p=polyfit(a(:,1),a(:,2),6); % 多項式曲線擬合
fprintf('order of polynomial is 6')
p
t=0.1:0.001:0.95;
nev=polyval(p,t); % 多項式評估
plot(t,nev,a(:,1),a(:,2),'*')
axis([0 1.1 0.6 1.4]); % 設置軸限制和縱橫比
grid % 顯示或隱藏軸網格線
title('order of polynomial is 6')
xlabel('input data')
ylabel('output data')
pause % 暫時停止執行MATLAB
%
p=polyfit(a(:,1),a(:,2),8); % 多項式曲線擬合
fprintf('order of polynomial is 8')
p
t=0.1:0.001:0.95;
nev=polyval(p,t); % 多項式評估
plot(t,nev,a(:,1),a(:,2),'*')
axis([0 1.1 0.6 1.4]); % 設置軸限制和縱橫比
grid % 顯示或隱藏軸網格線
title('order of polynomial is 8')
xlabel('input data')
%
xx=0.1:0.01:1;
yy=spline(a(:,1),a(:,2),xx); % 三次樣條數據插值
plot(xx,yy,a(:,1),a(:,2),'*')
pause % 暫時停止執行MATLAB

2020-03-27

Part 1

1
2
3
4
5
6
7
8
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
x=0:0.01:5;
y=2.*sin(2.*pi.*x)+rand(1,501);
plot(x,y)
plot(x,y,"o")
hold on % 就不會清除前面的圖,而是重複畫上去。
plot(x,y)

Part 2

1
2
3
4
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
p=-1:0.1:1;
t=sin(6*p);
plot(p,t,'*')

2020-04-10

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
syms a t s x; % 符號變數a、t、s、x宣告
F=1-exp(-a*t);
G=laplace(F); % 拉普拉斯變換

simplifyFraction(G) % 簡化符號有理表達式

F1=1/s
Y=ilaplace(F1); % 拉普拉斯逆變換

F2=1/(s^2)
Y1=ilaplace(F2); % 拉普拉斯逆變換

F3=sin(x);
diff(F3) % 區分符號表達或功能

F4=cos(x);
diff(F4) % 區分符號表達或功能

int(F3)
int(F4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
ans =
a/(s*(a + s))

F1 =
1/s

F2 =
1/s^2

ans =
cos(x)

ans =
-sin(x)

ans =
-cos(x)

ans =
sin(x)

2020-04-17

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
13
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
clear M % 清除電影資料矩陣 M
n = 50; % 抓取 50 個畫面
figure('Renderer','zbuffer'); % Only used in MS Windows
peaks;
fprintf('抓取畫面中...\n');
for i = 1:n
view([-37.5+i*360/n, 30]); % 改變觀測角度
M(i) = getframe; % 抓取畫面,並存入電影資料矩陣 M
end
fprintf('播放電影中...\n');
movie(M, 3); % 播放電影三次

Part 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
clear M % 清除電影資料矩陣 M
r=linspace(0, 4, 30); % 圓盤的半徑
t=linspace(0, 2*pi, 50); % 圓盤的極座標角度
[rr, tt]=meshgrid(r, t);
xx=rr.*cos(tt); % 產生圓盤上的 x 座標
yy=rr.*sin(tt); % 產生圓盤上的 y 座標
zz=peaks(xx,yy); % 產生 peaks 在極座標的資料
n = 30; % 抓取 30 個畫面
scale = cos(linspace(0, 2*pi, n));
figure('Renderer','zbuffer'); % Only used in MS Windows
fprintf('抓取畫面中...\n');
for i = 1:n
surf(xx, yy, zz*scale(i)); % 畫圖
axis([-inf inf -inf inf -8.5 8.5]); % 固定圖軸的範圍
box on
M(i) = getframe; % 抓取畫面,並存入電影資料矩陣 M
end
fprintf('播放電影中...\n');
movie(M, 5); % 播放電影 5 次

Part 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
clear M % 清除電影資料矩陣 M
load clown.mat
image(X); colormap(map); % 畫出小丑臉
n = 30; % 抓取 30 個畫面
scale = cos(linspace(0, 2*pi, n));
fprintf('抓取畫面中...\n');
for i = 1:n
colormap(((i-1)*(1-map)+(n-i)*map)/(n-1)); % 改變色盤矩陣
M(i) = getframe; % 抓取畫面,並存入電影資料矩陣 M
end
fprintf('播放電影中...\n');
movie(M, -5); % 播放電影 5 次

Part 4

1
2
3
4
5
6
7
8
9
10
11
12
13
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
img=imread('rice.png');
n=100;

for i = 1:n;
figure(1);
imshow(img)
img=img+2;
M(i)=getframe;
end

movie(M,-5);

Part 5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
img=imread('rice.png');
imgRGB=zeros(256,256,3,'uint8');
imgRGB(:,:,1)=img;
imgRGB(:,:,2)=img;
imgRGB(:,:,3)=img;
imgRGB=double(imgRGB);
n=100;
for i = 1:n
figure(1)
imshow(uint8(imgRGB))

imgRGB(:,:,1)=imgRGB(:,:,1)+1;
imgRGB(:,:,2)=imgRGB(:,:,2)+2;
imgRGB(:,:,3)=imgRGB(:,:,3)+3;
M(i)=getframe;
end

movie(M,-100);

Part 6

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
img=imread('rice.png');
imgRGB=zeros(256,256,3,'uint8');
imgRGB(:,:,1)=img;
imgRGB(:,:,2)=img;
imgRGB(:,:,3)=img;
imgRGB=double(imgRGB);
n=100;

for i = 1:n
figure(1)
imshow(uint8(imgRGB))

imgRGB(:,:,1)=imgRGB(:,:,1)-2;
imgRGB(:,:,2)=imgRGB(:,:,2)+2;
imgRGB(:,:,3)=imgRGB(:,:,3)-2;
M(i)=getframe;
end

movie(M,-200);

Part 7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
img=imread('rice.png');
imgRGB=zeros(256,256,3,'double');
for i=1:255;
for j=1:255;
if img(i,j)>125
img(i,j)=1;
else
img(i,j)=0;
end
end
end

imgRGB(:,:,1)=img;
imgRGB(:,:,2)=img;
imgRGB(:,:,3)=img;

n=100
for i = 1:n
figure(1)
imshow(uint8(imgRGB))
imgRGB(:,:,2)=imgRGB(:,:,2).*1.2;
M(i)=getframe;
end

movie(M,100);

Part 8

1
2
3
4
5
6
7
8
9
10
11
12
13
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
x = 0:0.1:8*pi;
h = plot(x, tan(x).*exp(-x/5), 'EraseMode', 'xor');
axis([-inf inf -1 1]); % 設定圖軸的範圍
grid on % 畫出格線
tic
for i = 1:5000
y = tan(x-i/50).*exp(-x/5);
set(h, 'ydata', y); % 設定新的 y 座標
drawnow % 立即作圖
end
toc

Part 9

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
img=imread('rice.png');
imgRGB(:,:,1)=img;
imgRGB(:,:,2)=img;
imgRGB(:,:,3)=img;
imgRGB=double(imgRGB);
figure(1)

for i=1:10
imgRGB(:,:,2)=imgRGB(:,:,2)+4;
figure(1);
imshow(uint8(imgRGB)) % 顯示視窗
imwrite(uint8(imgRGB),[int2str(i) '.bmp']); % 寫入檔案
end

Part 10

1
2
3
4
5
6
7
8
9
10
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
for i=1:10
%img=imread([int2str(i) '.bmp']); % 讀取檔案
img=imread(['test (' int2str(i) ').bmp']); % 讀取檔案


%imwrite(img,['test' int2str(i) '.jpg']); % 寫入檔案
imwrite(img,['test' int2str(i) '.jpg'],'Quality',80); % 壓縮檔案
end

Part 11

1
2
3
4
5
6
7
8
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
he=zeros(10000,100);

tic % 開始計時
he=rand(100,100);
he(10000,100)=1;
toc % 結束計時
1
Elapsed time is 0.003694 seconds.

2020-04-24

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%% 泰勒級數展開
syms t; % 符號變數t宣告
fun5 = exp(-1*t) % 符號函數設定
% 輸出為fun5 = exp(-t)
taylor(fun5,'Order',8)
%%----------------------------
T1=taylor(sin(t),'Order',15)
figure % 創建圖形窗口
hold on % 就不會清除前面的圖,而是重複畫上去。
for t=0:0.01:2*pi
plot(t,t^13/6227020800 - t^11/39916800 + t^9/362880 - t^7/5040 + t^5/120 - t^3/6 + t,'ro') % plot(T1值)
end
for t=0:0.01:2*pi
plot(t,sin(t),"b.")
end

Part 2

1
2
3
4
5
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
%%
syms x % 符號變數x宣告
equ=(sec(x))^5
int(equ,'x')

個人額外補充

線條顏色字串對應

2020-05-15

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%
% 繪圖加按紐
%
clc;clear;close all; % 清除command window % 清除Workkspace % 關閉所有Figure的窗口

% 設定圖型大小
h0=figure('position',[15 50 500 500]); %[X Y XL YL] % X、Y為圖左下點角點位
set(gca,'position',[0.2 0.25 0.6 0.6]) %[X Y XL YL] % XL、XL為圖長和寬

% 繪圖運算區
x=0:0.01:1; % 0每次增加0.01,直到1
y1=cos(4*pi*x);
y2=tan(4*pi*x);
plot(x,y2)
title('Button use')
grid

% 觸發按鈕事件
%【...】跳至下一行
But1=['set(but2con,''value'',0),','plot(x,y1),'];
But2=['set(but1con,''value'',0),','plot(x,y2),'];

% 按鈕屬性
but1con=uicontrol(gcf,'style','togglebutton',...
'string','plot cos',... % 名稱
'value',0,...
'position',[20 20 60 60],... % [X Y XL YL]
'callback',But1); % 按鈕執行But1事件

but2con=uicontrol(gcf,'style','togglebutton',...
'string','plot tan',... % 名稱
'value',0,...
'position',[400 20 80 60],... % [X Y XL YL]
'callback',But2); % 按鈕執行But2事件

Part 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
% 繪圖加按紐 %
clc;clear;close all; % 清除command window % 清除Workkspace % 關閉所有Figure的窗口

% 設定圖型大小
h0=figure('toolbar','none',...
'position',[210 50 360 450]);
h1=axes('parent',h0,...
'position',[0.10 0.45 0.8 0.5],...
'visible','on');

% 繪圖運算區
x=-1*pi:0.05:pi;
y=sin(x);
plot(x,y,"r")
axis([-4 4 -2 2])

% 按鈕事件及屬性
Button1=uicontrol('parent',h0,...
'units','points',...
'style','pushbutton',...
'string','Button1',...
'fontsize',15,... % 文字大小
'backgroundcolor',[0.8 0.8 0.8],... % 數字越大越淡
'position',[28 100 80 20],...
'callback',[...
'strn=get(Edit1,''string'');,',... % 程式區
'n=str2num(strn);,',...
'y1=cos(n.*x);,',...
'plot(x,y1),',...
'grid,',...
'axis([-4 4 -2 2]),',...
]);
Button2=uicontrol('parent',h0,...
'units','points',...
'style','pushbutton',...
'string','Button2',...
'fontsize',15,... % 文字大小
'backgroundcolor',[0.8 0.8 0.8],...
'position',[28 70 80 20],...
'callback',[...
'strdn=get(Edit2,''string'');,',... % 程式區
'dn=str2num(strdn);,',...
'y2=2*exp(-0.7*x).*cos(dn.*x);,',...
'plot(x,y2),',...
'grid,',...
'axis([-4 4 -10 10]),',]);
Button3=uicontrol('parent',h0,...
'units','points',...
'tag','b3',...
'style','pushbutton',...
'string','結束',...
'ForegroundColor',[1 0 0],...
'fontsize',24,... % 文字大小
'backgroundcolor',[1 0.5 0.5],... % RGB顏色
'position',[185 20 60 40],... % [X Y XL YL]
'callback','close'); % 程式區

% 編輯器事件及屬性
Edit1=uicontrol('parent',h0,...
'units','points',...
'tag','Edit1',...
'style','edit',...
'fontsize',12,...
'string','5',...
'horizontalalignment','right',...
'backgroundcolor',[0.9 0.9 0.9],... % RGB顏色
'position',[210 100 35 20]); % [X Y XL YL]
Edit2=uicontrol('parent',h0,...
'units','points',...
'tag','Edit2',...
'style','edit',...
'fontsize',12,...
'string','10',...
'horizontalalignment','right',...
'backgroundcolor',[0.9 0.9 0.9],... % RGB顏色
'position',[210 70 35 20]); % [X Y XL YL]
% 標籤事件及屬性
Label1=uicontrol('parent',h0,...
'units','points',...
'tag','Label1',...
'style','text',...
'string','第一輸入',...
'fontsize',13,... % 文字大小
'backgroundcolor',[0.9 0.8 0.9],... % RGB顏色
'position',[149 100 60 20]); % [X Y XL YL]
Label2=uicontrol('parent',h0,...
'units','points',...
'tag','Label2',...
'style','text',...
'string','第二輸入',...
'fontsize',13,... % 文字大小
'backgroundcolor',[0.9 0.8 0.9],... % RGB顏色
'position',[149 70 60 20]); % [X Y XL YL]

2020-05-22

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%
% 繪圖加按紐,捲軸,標籤
%
clc;clear;close all; % 清除command window % 清除Workkspace % 關閉所有Figure的窗口

% 設定圖型大小
mw0=figure('toolbar','none',...
'position',[20 60 450 700]);
mw1=axes('parent',mw0,...
'position',[0.20 0.55 0.6 0.4],...
'visible','off');

% 繪圖運算區
[x y z]=peaks;
f1=surfl(x,y,z);
axis([-3 3 -3 3 -8 8])
colormap([0.5 0.5 0.5])
cdata=get(mw0,'colormap');
initcdata=cdata;

%%

% 捲軸事件及屬性
scroll1=uicontrol('parent',mw0,...
'style','slider',...
'min',0,...
'max',1,...
'value',cdata(1),...
'position',[20 150 400 20],...
'BackgroundColor',[1 0.9 0.9],...
'callback',['srl1k=get(scroll1,''value'');,',...% 取捲軸值
'cdata(1)=srl1k;,',...
'set(mw0,''colormap'',cdata);']);

scroll2=uicontrol('parent',mw0,...
'style','slider',...
'min',0,...
'max',1,...
'value',cdata(2),...
'position',[20 100 400 20],...
'BackgroundColor',[0.9 1 0.9],...
'callback',['srl2k=get(scroll2,''value'');,',...% 取捲軸值
'cdata(2)=srl2k;,',...
'set(mw0,''colormap'',cdata);']);

scroll3=uicontrol('parent',mw0,...
'style','slider',...
'min',0,...
'max',1,...
'value',cdata(3),...
'position',[20 50 400 20],...
'BackgroundColor',[0.9 0.9 1],...
'callback',['srl3k=get(scroll3,''value'');,',...% 取捲軸值
'cdata(3)=srl3k;,',...
'set(mw0,''colormap'',cdata);']);
%%
% 標籤事件及屬性

% 更改紅色成份標籤
Label1=uicontrol('parent',mw0,...
'style','text',...
'string','更改紅色成份:',...
'position',[-140 170 400 20]);
% 更改綠色成份標籤
Label2=uicontrol('parent',mw0,...
'style','text',...
'string','更改綠色成份:',...
'position',[-140 120 400 20]);
% 更改籃色成份標籤
Label3=uicontrol('parent',mw0,...
'style','text',...
'string','更改籃色成份:',...
'position',[-140 70 400 20]);
% 設定文字
Label3=uicontrol('parent',mw0,...
'style','text',...
'string','更改Peaks函數顏色成份',...
'fontsize',11,... % 文字大小
'position',[0 200 180 20]);
% 按鈕事件及屬性
% reset鈕
Button1=uicontrol('parent',mw0,...
'style','pushbutton',...
'string','Reset',...
'position',[120 5 60 40],...
'callback',['set(scroll1,''value'',initcdata(1));,',...% 還原捲軸值
'set(scroll2,''value'',initcdata(2));,',...
'set(scroll3,''value'',initcdata(3));,',...
'set(mw0,''colormap'',initcdata)']);
% close 鈕
Buttone2=uicontrol('parent',mw0,...
'style','pushbutton',...
'string','close',...
'position',[300 5 60 40],...
'callback','close');

2020-05-29

Part1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口

% [file]=uigetfile('*.jpg*','選擇文件');
% XX =imread([filename fillepath]);

[filename filepath indx] = uigetfile(...
{'*.jpg;*.bmp;l',...
'Files (*.jpg、*.bmp)';
'*.*', 'All Files (*.*)'}, ...
'Select a File',...
'MultiSelect', 'on');

[~,x]=size(filename)

for i=1:x
str=char(filename(i));
imwrite(imread([filepath str]),[str '.bmp']);
end

封裝 .m 程式

  1. 選擇列的AppsApplication Compiler
  1. 選擇add main file旁邊的+符號
  1. 選擇要封裝的.m檔案
  1. 點選Package進行封裝
  1. 選擇封裝目的地
  1. 開始封裝
  1. 封裝完成

2020-06-05

Part 1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
clc;clear;close all;  % 清除command window % 清除Workkspace % 關閉所有Figure的窗口
num=[1 2]
den=[1 1 -6 0];
[x y z]=residue(num,den)
[num1 den1]=residue(x,y,z)
%%

syms s; % 宣告s型態
expand(((s^2)*(s-2)*(s-1))) % expand乘開括弧展開
num=[1 -4 0 4];
den=[1 -3 2 0 0];
[x,y,z]=residue(num,den);


%%
syms s;
expand(((0.0178+0.00356/s)*(100/s*(0.1*s+1)*(0.2*s+1))))/(1+((0.0178+0.00256/s))) % expand乘開括弧展開
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
num =
1 2

x =
-0.0667
0.4000
-0.3333

y =
-3
2
0

z =
[]

num1 =
0.0000 1.0000 2.0000


den1 =
1 1 -6 0

ans =
s^4 - 3*s^3 + 2*s^2

ans =
((89*s)/2500 + 4717/(2500*s) + 89/(250*s^2) + 1691/3125)/(8/(3125*s) + 5089/5000)

Part2

1
2
3
4
5
t=0:0.0001:1/60;
f=60;
x=2*sin(2.*pi.*t.*f);

plot(t,x)

個人額外補充

Part1

1
2
3
4
5
6
clc;clear;close all;
f=60;
t=0:0.01:1;
x=tan(4*pi*t);

plot(t/f*4,x/2)

Part2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
clc;clear;close all;
figure('position',[700 500 300 100]); % [X Y XL YL] % XY 視窗座標 % XL YL 視窗大小
But1=['set(but1con,''value'',0)'];
But2=['set(but2con,''value'',0)'];
but1con=uicontrol(gcf,'style','togglebutton',...
'string','按鈕一',... % 按鈕名稱
'value',0,...
'position',[40 20 80 60],... % [X Y XL YL]
'callback',But1); % 按鈕執行But1 事件
but2con=uicontrol(gcf,'style','togglebutton',...
'string','按鈕二',... % 按鈕名稱
'value',0,...
'position',[180 20 80 60],... % [X Y XL YL]
'callback',But2); % 按鈕執行But2 事件
1
2
3
4
5
clc;clear;close all;
num=[0 0 4]; % 設定分子多項式(依階往下寫)
den=[1 2 4]; % 設定分母多項式(依階往下寫)
[x y z]=residue(num,den)
[Num Den]=residue(x,y,z)
1
2
3
4
5
6
7
8
9
10
11
12
x =
0.0000 - 1.1547i
0.0000 + 1.1547i
y =
-1.0000 + 1.7321i
-1.0000 - 1.7321i
z =
[]
Num =
0 4
Den =
1.0000 2.0000 4.0000

Part3

1
2
3
4
5
clc;clear;close all;
f=3;
t=0:0.0001:1/f;
x=2*sin(2.*pi.*t.*f);
plot(t,x)

Part4

1
2
3
4
5
clc;clear;close all;
f=150;
t=0:0.0001:1;
x=500*sin(2*pi*f*t)+200*cos(2*pi*f*t);
plot(t,x)