当前位置:网站首页>2021年数学建模B组代码
2021年数学建模B组代码
2022-07-28 20:23:00 【sparename】
第一问
clc
clear
%%
data=xlsread('附件 1.xlsx');%加载数据
load('zu.mat');%加载数据21组
for i=1:length(unique(zu))%i从1:21
A(i)={
data(find(zu==i),:)}%定义一个元组,分成21组
end
%%
for i=1:5
for j=1:4
subplot(4,5,(i-1)*4+j);%4*5的方块,在4*5方块的哪个位置
B=A{
1,(i-1)*4+j};%提取A中在4*5方块的各个位置的数据
plot(B(:,1),B(:,2),B(:,1),B(:,4));%B中第1列,第2列画图,B中第1列,第4列画图
hold on
xlabel('温度/C');%x标签
ylabel('百分比/%');%y标签
title(sprintf('催化剂组合%i\n',(i-1)*4+j));%每次组合标题
end
end
%%
legend('乙醇转化率','C4烯烃选择率'); %右上角标注
%%
% 每组画图
figure(2)%创建新窗口
for i=1:21
B=A{
1,i};%提取A中每组数据
plot(B(:,1),B(:,2));
[b,bint,r,rint,stats]=regress(n',t); hold on end %% %每组标注 for i=1:21 str{i}=['催化剂组合',num2str(i)]; end legend(str); %% title('不同组合乙醇转化率随温度变化图'); xlabel('温度/C');%x标签 ylabel('百分比/%');%y标签 %% % 每组画图 figure(3)%创建新窗口 for i=1:21 B=A{1,i};%提取A中每组数据 plot(B(:,1),B(:,4)); hold on end %% %每组标注 for i=1:21 str{i}=['催化剂组合',num2str(i)]; end legend(str); %% title('不同组合C4烯烃选择率随温度变化图'); xlabel('温度/C');%x标签 ylabel('百分比/%');%y标签
%%
% 乙醇转化率
x=[1:21];
y=[250,275,300,325,350,400,450];%最多的温度列
for i=1:length(x)
for j=1:length(y)
B=A{
1,i};%提取A中21组每组数据
if j<=length(B(:,1))%如果21组中第1列温度列少于y
Z(i,j)=B(j,2);%直接赋值等于B中第2列乙醇转化率
else
Z(i,j)=0;%长度大于y
end
end
end
% cftool
%%
% C4烯烃选择率
x=[1:21];
y=[250,275,300,325,350,400,450];%最多的温度列
for i=1:length(x)
for j=1:length(y)
B=A{
1,i};%提取A中21组每组数据
if j<=length(B(:,1))%如果21组中第1列温度列少于y
Z(i,j)=B(j,4);%直接赋值等于B中第4列C4烯烃选择率
else
Z(i,j)=0;%长度大于y
end
end
end
cftool
第二问
clc
clear
%%
data=xlsread("附件 2.xlsx")%加载数据
for i=1:7
%绘制时间列与各列的关系图形
subplot(2,4,i)
plot(data(:,1),data(:,i+1));
switch(i)
case 1
xlabel('时间/min');%x 标签
ylabel('乙醇转化率/%');%y 标签
title(sprintf('时间与乙醇转化率组合'));%每次组合标题
case 2
xlabel('时间/min');%x 标签
ylabel('乙烯选择性/%');%y 标签
title(sprintf('时间与乙烯选择性组合'));%每次组合标题
case 3
xlabel('时间/min');%x 标签
ylabel('C4 烯烃选择性/%');%y 标签
title(sprintf('时间与 C4 烯烃选择性组合'));%每次组合标题
case 4
xlabel('时间/min');%x 标签
ylabel('乙醛选择性/%');%y 标签
title(sprintf('时间与乙醛选择性组合'));%每次组合标题
case 5
xlabel('时间/min');%x 标签
ylabel('碳数为 4-12 脂肪醇/%');%y 标签
title(sprintf('时间与碳数为 4-12 脂肪醇组合'));%每次组合标题
case 6
xlabel('时间/min');%x 标签
ylabel('甲基苯甲醛和甲基苯甲醇/%');%y 标签
23
title(sprintf('时间与甲基苯甲醛和甲基苯甲醇组合'));%每次组合标题
otherwise
xlabel('时间/min');%x 标签
ylabel('其他/%');%y 标签
title(sprintf('时间与其他组合'));%每次组合标题
end
end
遗传算法求最优解
clc,clear
options=gaoptimset('Generations',800,'StallGenLimit',300,'PopInitRange',[0.25 0.15 0.24 5 250;7.5 3.05 1.5 300 400],'PlotFcns',@gaplotbestf);
[x,f]=ga(@SA,5,options)
function f=SA(x)
if (x(1)>7.5|x(1)<0.25|x(2)>3.05|x(2)<0.15|x(3)>1.5|x(3)<0.24627|x(4)>300|x(4)<5|x(5)>400|x(5)<250)%变量范围
f=0; %s适应度
else
a=(-41.909616+12.75438*x(3)+0.108627*x(4)+0.00052319939932*(x(5)^2)-8.519519*(x(2)/x(3)));
b=(-20.530653-3.239872.*x(1)+2.892962.*x(2)+0.086185*x(3)*x(4)+0.0002875058634*(x(5)^2));
f=-a*b; %由于只能求最小值,加一个-号反向求最大值
end
end
边栏推荐
- C语言编程规范学习笔记和总结
- 世界肝炎日 | 基层也能享受三甲资源,智慧医疗系统如何解决“看病难”?
- [NLP] generate word cloud
- What technology is needed for applet development
- Kubevera plug-in addons download address
- kali里的powersploit、evasion、weevely等工具的杂项记录
- PCB材料简单介绍
- fluke dtx-1800测试精度有必要进行原厂校准吗?
- 字节一面:TCP 和 UDP 可以使用同一个端口吗?
- For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa
猜你喜欢

腾讯云数据库负责人林晓斌借一亿元炒股?知情人士:金额不实

Apifox:满足你对 Api 的所有幻想

使用Mock技术帮助提升测试效率的小tips,你知道几个?

Chinese patent keyword extraction based on LSTM and logistic regression

Leetcode · 581. shortest unordered continuous subarray · double pointer

How to design workflow engine gracefully (glory Collection Edition)

How to skillfully use assertion + exception handling classes to make the code more concise! (glory Collection Edition)

System Analyst

For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa

Versailles ceiling: "the monthly salary of two years after graduation is only 35K, which is really unpromising ~ ~"
随机推荐
How to design workflow engine gracefully (glory Collection Edition)
罗克韦尔AB PLC RSLogix数字量IO模块基本介绍
使用Mock技术帮助提升测试效率的小tips,你知道几个?
Differences of display values
基于对象的实时空间音频渲染丨Dev for Dev 专栏
小程序开发需要什么技术
Aimbetter insight into your database, DPM and APM solutions
字节一面:TCP 和 UDP 可以使用同一个端口吗?
HYDAC溢流阀DB08A-01-C-N-500V
The applet listens for the target node to appear on the screen
HCIA comprehensive experiment (take Huawei ENSP as an example)
如何高效、精准地进行图片搜索?看看轻量化视觉预训练模型
基于知识元的外文专利文献知识描述框架
数据插值——对不同量级的数据进行归一化
Storage and steps of phospholipid coupled antibody / protein Kit
Practice and exploration of overseas site Seata of ant group
Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
Kubevera plug-in addons download address
Implementation of sequence table
Research on intangible cultural heritage image classification based on multimodal fusion