利用MATLAB计算 生物韵律(biorhythm)的周期
利用MATLAB计算 生物韵律(biorhythm)的周期
生物韵律(biorhythm)是100多年前被发现的,1960年左右进入我们的公众文化。现在你仍然可以发现很多能给出个性化生物韵律或兜售能计算生物韵律软件的网站。生物韵律是建立在三个正弦周期就能影响我们生活这样的观念上的。体力周期为23天,情感周期为28天,智力周期为33天。对每个人来说,这些周期的起始点是出生的那一天。
工具/原料
输入输出设备:个人PC计算机一台 ( 笔记本电脑最好,因为集成了显示器、键盘和鼠标 )
软件运行环境:version 9.5 (R2018b) of the MATLAB Runtime
独立可执行程序:biorhythm.exe 或者 biorhythm.m + MATLAB R2018b
方法/步骤
步骤一
首先安装完Visual Studio 2017;
在matlab命令行输入mbuild -setup命令(注意mbuild和-setup之间应有一个空格; -是在英文输入法状态下键入的减号)。
在当前目录下找到biorhythm.m程序脚本;
然后在命令行键入: mcc -m biorhythm.m 后回车,等待.exe程序编译完成。
步骤二
如果电脑之前从未安装过 MATLAB R2018b,那么此时双击打开生成的biorhythm.exe是没法运行,因为需要调用的动态链接库函数环境文件还没有安装。
Download and install the Windows version of the MATLAB Runtime for R2018b from the following link on the MathWorks website:
http://www.mathworks.com/products/compiler/mcr/index.html
解决方法是从MATLAB官网下载MATLAB Runtime for R2018b并安装,网址见上面给出的链接。
步骤三
在按照上面教程完成步骤一和步骤二后,我们可以双击打开biorhythm.exe (可以自己用下面给出的源代码自己编译biorhythm.m)
控制台输入出生生日后回车,经过几秒钟后会自动绘制出以当前日期为对称轴的
生物韵律图 图例位于左下角

附录biorhythm.m源代码:
function biorhythm(birthday,plotday)
% BIORHYTHM Plot of your biorhythm for an 8 week period.
%
% BIORHYTHM('birthday','plotday')
% BIORHYTHM('birthday') uses today for plotday.
% BIORHYTHM with no arguments prompts for birthday.
% Example:
% biorhythm('July 6, 1946')
%
% Biorhythms were very popular in the '60's. You can still find
% many Web sites today that offer to prepare personalized biorhythms,
% or that sell software to compute them.
% Biorhythms are based on the notion that three sinusoidal cycles
% influence our lives. The physical cycle has a period of 23 days,
% the emotional cycle has a period of 28 days, and the intellectual
% cycle has a period of 33 days. For any individual, the cycles are
% initialized at birth.
%
if nargin < 1
birthday = input('When is your birthday? ','s')
end
if nargin < 2
plotday = datestr(fix(now));
end
t0 = datenum(birthday);
t1 = datenum(plotday);
clf
shg
axes('position',[.10 .30 .80 .50])
t = (t1-28):1:(t1+28);
y = 100*[sin(2pi(t-t0)/23); sin(2pi(t-t0)/28); sin(2pi(t-t0)/33)];
plot(t,y)
line([t1 t1],[-100 100],'color','k')
set(gca,'xtick',(t1-28):7:(t1+28))
datetick('x',6,'keeplimits','keepticks')
text(t1-3,-130,datestr(t1,1))
title(['birthday: ' datestr(birthday,1)])
axis tight
l1 = legend('Physical','Emotional','Intellectual');
set(l1,'pos',[.10 .02 .18 .12])
