sgltest1.m

来自「MATLAB扩展编程by 孙永康.ZIP.有需要的朋友请来下载.」· M 代码 · 共 19 行

M
19
字号
function sgltest1(n)

if isstr(n)
	n = str2num(n);
end

x = sin([1:n]/n*(16*pi));
y = abs(fft(x));
y = y(1:n/2);
[m i] = max(y);

subplot(211)
plot(x)
subplot(212)
plot(y)

s = sprintf('Max = %d, Index = %d\n', m, i);
uiwait(msgbox(s, 'Result', 'modal'));
close

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?