Matlab模拟布朗运动
1 简介
利用matlab工具模拟了布朗运动测量的实验。通过一正态随机数产生函数模拟从而产生布朗运动步距。在假定粒子所受拖曳力满足斯托克斯关系的情况下,通过拟合多个粒子的均方位移随时间的变化曲线得到斜率,从而进一步可得出扩散系数和波尔兹曼常数。同时,根据模拟结果也对如何减小实验误差作了分析。
2 完整代码
function varargout = bulang(varargin)
% BULANG M-file for bulang.fig
% BULANG, by itself, creates a new BULANG or raises the existing
% singleton*.
%
% H = BULANG returns the handle to a new BULANG or the handle to
% the existing singleton*.
%
% BULANG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BULANG.M with the given input arguments.
%
% BULANG('Property','Value',...) creates a new BULANG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before bulang_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to bulang_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help bulang
% Last Modified by GUIDE v2.5 13-Sep-2021 13:42:21
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @bulang_OpeningFcn, ...
'gui_OutputFcn', @bulang_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before bulang is made visible.
function bulang_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to bulang (see VARARGIN)
% Choose default command line output for bulang
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes bulang wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = bulang_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
global k;
k=str2double(get(hObject,'string'));
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
global k;
n=50;
x=rand(n,1)-0.5;
y=rand(n,1)-0.5;
h=plot(x,y,'.');
axis([-1 1 -1 1]);
axis square;
grid off;
set(h,'EraseMode','Xor','MarkerSize',24);
if k>=0;
for i=linspace(1,10,10000)
drawnow
x=x+k/10000.*randn(n,1);
y=y+k/10000.*randn(n,1);
set(h,'xdata',x,'ydata',y);
end
else
input('Error');
end
% --------------------------------------------------------------------
function Quit_Callback(hObject, eventdata, handles)
% hObject handle to Quit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
3 仿真结果
4 参考文献
[1]冉诗勇. 利用Matlab模拟布朗运动测量实验[J]. 大学物理实验, 2011, 24(6):4.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
Matlab模拟布朗运动相关推荐
- Matlab:利用Matlab实现布朗运动模拟
Matlab:利用Matlab实现布朗运动模拟 目录 输出结果 实现代码 输出结果 实现代码 n=40 s=0.04 x=rand(n,1)-0.5; y=rand(n,1)-0.5; h=plot( ...
- MatLab实现布朗运动
写MATLAB程序,画出动画来模拟粒子的布朗运动. 在二维坐标系下,假设有100个点,起始坐标都为(0,0),在坐标系下用.画出这100个点.模拟这些点的布朗运动,试写出含有1000步的循环,每一步循 ...
- MATLAB中如何让分度值小点,实验6 干涉的matlab模拟.doc
实验6 干涉的matlab模拟.doc MATLAB在光信息处理中的应用课程上机实验(三峡大学2013年)实验6干涉的MATLAB模拟一.实验目的掌握双缝干涉.牛顿环的MATLAB模拟.二.实验内容1 ...
- matlab模拟简单孔径衍射图样,夫琅和费衍射实验文献综述
夫琅和费衍射就是光源和观察幕离障碍物(孔或屏)均为无穷远的衍射现象,又称远场衍射,在实际操作中,可通过一个凸透镜,将无穷远处的衍射图样移至凸透镜的像方焦面上观察.可在观察幕中央看到一条特别明亮的亮条纹 ...
- 加加速度matlab,关于加加速度的若干机械运动分析及MATLAB模拟
收稿日期:2004 - 04 - 06 基金项目:遵义师范学院科研基金资助项目(2003012) 作者简介:董水金(1946 -) ,男 ,江苏无锡人 ,遵义师范学院物理系副教授 ,主要从事电子技术和 ...
- matlab偶极矩电场强度分布图_课程设计用MATLAB模拟偶极子的电场分布.doc
课程设计用MATLAB模拟偶极子的电场分布 燕山大学 课 程 设 计 说 明 书 题目: 用MATLAB模拟偶极子的电场分布 学院(系): 年级专业: 学 号: 学生姓名: 指导教师: 教师职称: 燕 ...
- MATLAB模拟导热过程,一维热传导MATLAB模拟.doc
PAGE 昆 明 学 院 2015 届毕业设计(论文) 设计(论文)题目 一维热传导问题的数值解法及其MATLAB模拟 子课题题目 无 姓 名 伍有超 学 号 201117030225 所 属 系 物 ...
- 布丰投针java实现,MATLAB模拟布丰投针实验
MATLAB模拟布丰投针实验 标签(空格分隔): 算法 Buffon's Needle 桌面上有距离为a的若干平行线,将长度为L的针随机丢在桌面上,则这根针与平行线相交的概率是多少?假定L < ...
- 基于Matlab模拟哈特曼波前探测器
哈特曼波前探测器(Shack-Hartmann Wavefront Sensor, SHWFS)[1]用于测量波前像差,本文介绍如何用Matlab模拟SHWFS工作过程,即从像差中获得光点阵图像.计算 ...
- MATLAB模拟陀螺仪的运动轨迹(附完整代码)
本文讲述了陀螺仪运动轨迹的分析过程,并且通过MATLAB进行仿真. 顺时针旋转 MATLAB陀螺仪运动轨迹仿真(正转) 逆时针旋转 MATLAB陀螺仪运动轨迹仿真(反转) 第一步:建立坐标系 假设陀螺 ...
最新文章
- PL/SQL程序设计 第七章 包的创建和应用
- 阿里120页PPT诠释国家“智能+”战略
- 角色与网站地图的结合
- Ubuntu 16.04 安装 VMware-Workstation-12
- openresty nginx php,diy 你的nginx-OpenResty
- mysql数据库设置索引 以下_如何设置MySQL数据库表的索引总长度
- C#编程(六十六)----------表达式树总结
- 大数据分析对企业运营的价值体现
- 梦幻一场——关于《梦断代码》
- python new 干什么用_详解Python中的__new__()方法的使用
- python金融股票市场数据分析神器TA-Lib学习使用
- 嵌入式USB转RS232九针串口线驱动,及串口软件secureCRT的使用
- eclipse svn同步代码缓慢、未响应
- 【WiFi】WiFi 5G 信道、频宽对应关系及支持的信道列表
- 转《DB2操作指南及命令大全》
- 金蝶云星空二次开发-数据库存查询
- 函数发生器的使用方法
- Completed 406 NOT_ACCEPTABLE
- java伪随机数概率_抽奖伪随机数生成器(Java)
- 一篇非大厂的 Android 面试总结心得~