美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx

上传人:b****2 文档编号:20267335 上传时间:2023-04-25 格式:DOCX 页数:21 大小:18.01KB
下载 相关 举报
美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx_第1页
第1页 / 共21页
美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx_第2页
第2页 / 共21页
美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx_第3页
第3页 / 共21页
美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx_第4页
第4页 / 共21页
美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx

《美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx》由会员分享,可在线阅读,更多相关《美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx(21页珍藏版)》请在冰豆网上搜索。

美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉.docx

美赛A题基于某NS模型的超车模型Matlab代码新鲜出炉

plotbutton=uicontrol('style','pushbutton',...

'string','Run',...

'fontsize',12,...

'position',[100,400,50,20],...

'callback','run=1;');

%definethestopbutton

erasebutton=uicontrol('style','pushbutton',...

'string','Stop',...

'fontsize',12,...

'position',[200,400,50,20],...

'callback','freeze=1;');

%definetheQuitbutton

quitbutton=uicontrol('style','pushbutton',...

'string','Quit',...

'fontsize',12,...

'position',[300,400,50,20],...

'callback','stop=1;close;');

number=uicontrol('style','text',...

'string','1',...

'fontsize',12,...

'position',[20,400,50,20]);

%==============================

%CAsetup

n=128;

%initializethearrays

z=zeros(n,n);

cells=z;

sum=z;

%setafewcellstoone

cells(n/2,.25*n:

.75*n)=1;

cells(.25*n:

.75*n,n/2)=1;

%cells(.5*n-1,.5*n-1)=1;

%cells(.5*n-2,.5*n-2)=1;

%cells(.5*n-3,.5*n-3)=1;

cells=(rand(n,n))<.5;

%howlongforeachcasetostabilityorsimpleoscillators

%buildanimageanddisplayit

imh=image(cat(3,cells,z,z));

set(imh,'erasemode','none')

axisequal

axistight

%indexdefinitionforcellupdate

x=2:

n-1;

y=2:

n-1;

%Maineventloop

stop=0;%waitforaquitbuttonpush

run=0;%waitforadraw

freeze=0;%waitforafreeze

while(stop==0)

if(run==1)

%nearestneighborsum

sum(x,y)=cells(x,y-1)+cells(x,y+1)+...

cells(x-1,y)+cells(x+1,y)+...

cells(x-1,y-1)+cells(x-1,y+1)+...

cells(3:

n,y-1)+cells(x+1,y+1);

%TheCArule

cells=(sum==3)|(sum==2&cells);

%drawthenewimage

set(imh,'cdata',cat(3,cells,z,z))

%updatethestepnumberdiaplay

stepnumber=1+str2num(get(number,'string'));

set(number,'string',num2str(stepnumber))

end

if(freeze==1)

run=0;

freeze=0;

end

drawnow%needthisintheloopforcontrolstowork

end

2、SurfaceTension

%Conway'slifewithGUI

clf;clearall

%=============================================

%buildtheGUI

%definetheplotbutton

plotbutton=uicontrol('style','pushbutton',...

'string','Run',...

'fontsize',12,...

'position',[100,400,50,20],...

'callback','run=1;');

%definethestopbutton

erasebutton=uicontrol('style','pushbutton',...

'string','Stop',...

'fontsize',12,...

'position',[200,400,50,20],...

'callback','freeze=1;');

%definetheQuitbutton

quitbutton=uicontrol('style','pushbutton',...

'string','Quit',...

'fontsize',12,...

'position',[300,400,50,20],...

'callback','stop=1;close;');

number=uicontrol('style','text',...

'string','1',...

'fontsize',12,...

'position',[20,400,50,20]);

%=============================================

%CAsetup

n=128;

%initializethearrays

z=zeros(n,n);

cells=z;

sum=z;

%setafewcellstoone

cells(n/2,.25*n:

.75*n)=1;

cells(.25*n:

.75*n,n/2)=1;

%cells(.5*n-1,.5*n-1)=1;

%cells(.5*n-2,.5*n-2)=1;

%cells(.5*n-3,.5*n-3)=1;

cells=(rand(n,n))<.5;

%howlongforeachcasetostabilityorsimpleoscillators

%buildanimageanddisplayit

imh=image(cat(3,cells,z,z));

set(imh,'erasemode','none')

axisequal

axistight

%indexdefinitionforcellupdate

x=2:

n-1;

y=2:

n-1;

%Maineventloop

stop=0;%waitforaquitbuttonpush

run=0;%waitforadraw

freeze=0;%waitforafreeze

while(stop==0)

if(run==1)

%nearestneighborsum

sum(x,y)=cells(x,y-1)+cells(x,y+1)+...

cells(x-1,y)+cells(x+1,y)+...

cells(x-1,y-1)+cells(x-1,y+1)+...

cells(3:

n,y-1)+cells(x+1,y+1)+...

cells(x,y);

%TheCArule

cells=~((sum<4)|(sum==5));

%drawthenewimage

set(imh,'cdata',cat(3,cells,z,z))

%updatethestepnumberdiaplay

stepnumber=1+str2num(get(number,'string'));

set(number,'string',num2str(stepnumber))

end

if(freeze==1)

run=0;

freeze=0;

end

drawnow%needthisintheloopforcontrolstowork

end

3、PercolationCluster

%PercolationCluster

clf

clearall

threshold=.63;

%

ax=axes('units','pixels','position',[11500400],'color','k');

text('units','pixels','position',[50,255,0],...

'string','BioNB','color','w','fontname','helvetica','fontsize',100)

text('units','pixels','position',[120,120,0],...

'string','441','color','w','fontname','helvetica','fontsize',100)

initial=getframe(gca);

[a,b,c]=size(initial.cdata);

z=zeros(a,b);

cells=double(initial.cdata(:

:

1)==255);

visit=z;

sum=z;

imh=image(cat(3,z,cells,z));

set(imh,'erasemode','none')

%return

fori=1:

100

sum(2:

a-1,2:

b-1)=cells(2:

a-1,1:

b-2)+cells(2:

a-1,3:

b)+...

cells(1:

a-2,2:

b-1)+cells(3:

a,2:

b-1)+...

cells(1:

a-2,1:

b-2)+cells(1:

a-2,3:

b)+...

cells(3:

a,1:

b-2)+cells(3:

a,3:

b);

pick=rand(a,b);

%edgesonly

%cells=(cells&(sum<8))|((sum>=1)&(pick>=threshold)&(visit==0));

cells=cells|((sum>=1)&(pick>=threshold)&(visit==0));

visit=(sum>=1);%&(pick

set(imh,'cdata',cat(3,z,cells,z))

drawnow

end

return

figure

(2)

image(cat(3,z,cells,z))

4、Excitablemedia(BZreactionorheart)

%CAdriver

%excitablemedia

clf;clearall

n=128;

z=zeros(n,n);

cells=z;

cells=(rand(n,n))<.1;

%cells(n/2,n*.25:

n*.75)=1;

%cells(n*.25:

n*.75,n/2)=1;

sum=z;

imh=image(cat(3,cells,z,z));

set(imh,'erasemode','none')

axisequal

axistight

x=[2:

n-1];y=[2:

n-1];

t=6;%centervalue=6;7makesfastpattern;5analiatingwaves

t1=3;%centervalue=3

fori=1:

1200

sum(x,y)=((cells(x,y-1)>0)&(cells(x,y-1)0)&(cells(x,y+1)

((cells(x-1,y)>0)&(cells(x-1,y)0)&(cells(x+1,y)

((cells(x-1,y-1)>0)&(cells(x-1,y-1)0)&(cells(x-1,y+1)

((cells(x+1,y-1)>0)&(cells(x+1,y-1)0)&(cells(x+1,y+1)

cells=((cells==0)&(sum>=t1))+...

2*(cells==1)+...

3*(cells==2)+...

4*(cells==3)+...

5*(cells==4)+...

6*(cells==5)+...

7*(cells==6)+...

8*(cells==7)+...

9*(cells==8)+...

0*(cells==9);

set(imh,'cdata',cat(3,z,cells/10,z))

drawnow

end

5、ForestFire

%CAdriver

%

%forestfire

clf

clearall

n=100;

Plightning=.000005;

Pgrowth=.01;%.01

z=zeros(n,n);

o=ones(n,n);

veg=z;

sum=z;

imh=image(cat(3,z,veg*.02,z));

set(imh,'erasemode','none')

axisequal

axistight

%burning->empty

%green->burningifoneneigborburningorwithprob=f(lightning)

%empty->greenwithprob=p(growth)

%veg={empty=0burning=1green=2}

fori=1:

3000

%nearbyfires?

sum=(veg(1:

n,[n1:

n-1])==1)+(veg(1:

n,[2:

n1])==1)+...

(veg([n1:

n-1],1:

n)==1)+(veg([2:

n1],1:

n)==1);

veg=...

2*(veg==2)-((veg==2)&(sum>0|(rand(n,n)

2*((veg==0)&rand(n,n)

set(imh,'cdata',cat(3,(veg==1),(veg==2),z))

drawnow

end

6、Gasdynamics

%CAdriver

%HPP-gas

clearall

clf

nx=52;%mustbedivisibleby4

ny=100;

z=zeros(nx,ny);

o=ones(nx,ny);

sand=z;

sandNew=z;

gnd=z;

diag1=z;

diag2=z;

and12=z;

or12=z;

sums=z;

orsum=z;

gnd(1:

nx,ny-3)=1;%rightgroundline

gnd(1:

nx,3)=1;%leftgroundline

gnd(nx/4:

nx/2-2,ny/2)=1;%theholeline

gnd(nx/2+2:

nx,ny/2)=1;%theholeline

gnd(nx/4,1:

ny)=1;%topline

gnd(3*nx/4,1:

ny)=1;%bottomline

%filltheleftside

r=rand(nx,ny);

sand(nx/4+1:

3*nx/4-1,4:

ny/2-1)=r(nx/4+1:

3*nx/4-1,4:

ny/2-1)<0.3;

%sand(nx/4+1:

3*nx/4-1,ny*.75:

ny-4)=r(nx/4+1:

3*nx/4-1,ny*.75:

ny-4)<0.75;

%sand(nx/2,ny/2)=1;

%sand(nx/2+1,ny/2+1)=1;

imh=image(cat(3,z,sand,gnd));

set(imh,'erasemode','none')

axisequal

axistight

fori=1:

1000

p=mod(i,2);%margolisneighborhood

%upperleftcellupdate

xind=[1+p:

2:

nx-2+p];

yind=[1+p:

2:

ny-2+p];

%Seeifexactlyonediagonalisones

%only(atmost)oneofthefollowingcanbetrue!

diag1(xind,yind)=(sand(xind,yind)==1)&(sand(xind+1,yind+1)==1)&...

(sand(xind+1,yind)==0)&(sand(xind,yind+1)==0);

diag2(xind,yind)=(sand(xind+1,yind)==1)&(sand(xind,yind+1)==1)&...

(sand(xind,yind)==0)&(sand(xind+1,yind+1)==0);

%Thediagonalsbothnotoccupiedbytwoparticles

and12(xind,yind)=(diag1(xind,yind)==0)&(diag2(xind,yind)==0);

%Onediagonalisoccupiedbytwoparticles

or12(xind,yind)=diag1(xind,yind)|diag2(xind,yind);

%foreverygasparticleseeifitneartheboundary

sums(xind,yind)=gnd(xind,yind)|gnd(xind+1,yind)|...

gnd(xind,yind+1)|gnd(xind+1,yind+1);

%celllayout:

%x,yx+1,y

%x,y+1x+1,y+1

%If(nowalls)and(diagonalsarebothnotoccupied)

%thenthereisnocollision,somoveoppositecelltocurrentcell

%If(nowalls)and(onlyonediagonalisoccupied)

%thenthereisacollisionsomoveccwcelltothecurrentcell

%If(awall)

%thendon'tchangethecell(causesareflection)

sandNew(xind,yind)=...

(and12(xind,yind)&~sums(xind,yind)&sand(xind+1,yind+1))+...

(or12(xind,yind)&~sums(xind,yind)&sand(xind,yind+1))+...

(sums(xind,yind)&sand(xind,yind));

sandNew(xind+1,yind)=...

(and12(xind,yind)&~sums(xind,yind)&sand(xind,yind+1))+...

(or12(xind,yind)&~sums(xind,yind)&sand(xind,yind))+...

(sums(xind,yind)&sand(xind+1,yind));

sandNew(xind,yind+1)=...

(and12(xind,yind)&~sums(xind,yind)&sand(xind+1,yind))+...

(or12(xind,yind)&~sums(xind,yind)&sand(xind+1,yind+1))+...

(sums(xind,yind)&sand(xind,yind+1));

sandNew(xind+1,yind+1)=...

(and12(xind,yind)&~sums(xind,yin

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1