1286 0

[Weka及其他] MATLAB课程:代码示例之Mathematics(一) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.4857
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399203 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-7 12:35:54 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Mathematics(一)


Using FFT


This example shows how to use the FFT function to analyze the variations in sunspot activity over the last 300 years.


Sunspot activity is cyclical, reaching a maximum about every 11 years. Let's confirm that. Here is a plot of a quantity called the Zurich sunspot relative number, which measures both number and size of sunspots. Astronomers have tabulated this number for almost 300 years.

load sunspot.datyear = sunspot(:,1);relNums = sunspot(:,2);plot(year,relNums)title('Sunspot Data')


Here is a closer look at the first 50 years.

plot(year(1:50),relNums(1:50),'b.-');


The fundamental tool of signal processing is the FFT, or fast Finite Fourier Transform. To take the FFT of the sunspot data type the following.

The first component of Y, Y(1), is simply the sum of the data, and can be removed.

Y = fft(relNums);Y(1) = [];


A graph of the distribution of the Fourier coefficients (given by Y) in the complex plane is pretty, but difficult to interpret. We need a more useful way of examining the data in Y.

plot(Y,'ro')title('Fourier Coefficients in the Complex Plane');xlabel('Real Axis');ylabel('Imaginary Axis');


The complex magnitude squared of Y is called the power, and a plot of power versus frequency is a "periodogram".

n = length(Y);power = abs(Y(1:floor(n/2))).^2;nyquist = 1/2;freq = (1:n/2)/(n/2)*nyquist;plot(freq,power)xlabel('cycles/year')title('Periodogram')


The scale in cycles/year is somewhat inconvenient. We can plot in years/cycle and estimate the length of one cycle.

plot(freq(1:40),power(1:40))xlabel('cycles/year')


Now we plot power versus period for convenience (where period = 1./freq). As expected, there is a very prominent cycle with a length of about 11 years.

period = 1./freq;plot(period,power);axis([0 40 0 2e+7]);ylabel('Power');xlabel('Period (Years/Cycle)');


Finally, we can fix the cycle length a little more precisely by picking out the strongest frequency. The red dot locates this point.

hold on;index = find(power == max(power));mainPeriodStr = num2str(period(index));plot(period(index),power(index),'r.', 'MarkerSize',25);text(period(index)+2,power(index),['Period = ',mainPeriodStr]);hold off;




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:mathematics Mathematic MATLAB课程 Thematic MATLAB MATLAB课程 代码示例 Mathematics MATLAB


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 17:32