Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
LYuhang
Matlab-GUI-Course-Design
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
Matlab-GUI-Course-Design
/
Simulate.m
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
44 lines (42 loc) · 1.45 KB
master
Breadcrumbs
Matlab-GUI-Course-Design
/
Simulate.m
Copy path
Top
File metadata and controls
Code
Blame
44 lines (42 loc) · 1.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
function [ weight_array, delta_weight_array, heat_array] = Simulate( W0, T, A1, A2, B1, B2, J, J0, Period)
% Simulate函数用于输入参数后仿真出在0~Period时间段内的
% 体重曲线,返回值为长度为Period的一维向量。
% W0 : 初始体重
% T : 每周运动时间
% A1 : 吸收热量与增加体重的关系
% A2 : 消耗热量与减少体重的关系
% B1 : 1kg体重每周正常代谢热量kcal
% B2 : 1kg体重每小时跑步消耗热量kcal
% J : 每周吸收热量减少量
% J0 : 第一周吸收的热量
% Period : 仿真的时间段
weight_array = zeros(1, Period); % 用于记录体重随时间变化
delta_weight_array = zeros(1, Period); % 用于记录体重减少量
heat_array = zeros(1, Period); % 用于记录吸收热量
weight_array(1) = W0;
for K = 1:Period
% 第K+1周吸收的热量
if K <= (J0-10000) / J
J_K_plus_1 = J0 - J * (K-1);
else
J_K_plus_1 = 10000;
end
heat_array(K) = J_K_plus_1;
% 正常代谢产生热量
J1_K_plus_1 = weight_array(K) * B1;
% 运动代谢产生热量
J2_K_plus_1 = weight_array(K) * T * B2;
% 代谢产生总热量
J_gen_K_plus_1 = J1_K_plus_1 + J2_K_plus_1;
% 如果吸收热量大于代谢热量,那么增重
if J_K_plus_1 >= J_gen_K_plus_1
delta_W = (J_K_plus_1 - J_gen_K_plus_1) * A1;
delta_weight_array(K) = delta_W;
weight_array(K+1) = weight_array(K) + delta_W;
% 如果吸收热量小于代谢热量,那么减重
else
delta_W = (J_gen_K_plus_1 - J_K_plus_1) * A2;
delta_weight_array(K) = -delta_W;
weight_array(K+1) = weight_array(K) - delta_W;
end
end
You can’t perform that action at this time.