function varargout = main(varargin)
% MAIN MATLAB code for main.fig
% MAIN, by itself, creates a new MAIN or raises the existing
% singleton*.
%
% H = MAIN returns the handle to a new MAIN or the handle to
% the existing singleton*.
%
% MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MAIN.M with the given input arguments.
%
% MAIN('Property','Value',...) creates a new MAIN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before main_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to main_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 main
% Last Modified by GUIDE v2.5 25-Apr-2024 22:37:18
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @main_OpeningFcn, ...
'gui_OutputFcn', @main_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 main is made visible.
function main_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 main (see VARARGIN)
% Choose default command line output for main
handles.output = hObject;
% Update handles structure
position = get(handles.pushbutton5,'Position');
I = imread('2.png'); %读取图片
I = imresize(I, [position(4)*1 position(3)*1]); %设置位置 第一个pos是高 第二个是宽(只能是整数)
set(handles.pushbutton5,'CData',I); %将按钮的背景图片设置成I
guidata(hObject, handles);
% UIWAIT makes main wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = main_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;
% --- Executes during object creation, after setting all properties.
function axes3_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes3
% --- 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)
w1=50; %各参数 w频率 k波数
w2=60;
k1=5;
k2=4;
a=1;
t=0.1:0.2:1.3; %对时间进行等间隔取点
x=0:0.001:10; %对传播方向x轴进行等间隔取点
%A1=a*cos(k1*x-w1*t(end));
%A2=a*cos(k2*x-w2*t(end));
fplot(handles.axes1,@(x) a*cos(k1*x-w1*t(end)),[0 10]*1,'Linewidth',1.5,'color',[0 0 255]/255); %蓝色
hold on;
fplot(handles.axes2,@(x) a*cos(k2*x-w2*t(end)),[0 10]*1,'Linewidth',1.5,'color',[255 0 0]/255); %红色
hold on;
xlabel(handles.axes1,'变量X');
ylabel(handles.axes1,'振幅'); %x处的波强
legend(handles.axes1,'光波1');
xlabel(handles.axes2,'变量X');
ylabel(handles.axes2,'振幅'); %x处的波强
legend(handles.axes2,'光波2');
hold off;
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
w1=50; %各参数 w频率 k波数
w2=60;
k1=5;
k2=4;
a=1;
x=0:0.001:10;
k=0;
m2=moviein(length(0.1:0.001:0.5));
for t=0.1:0.2:1.3 %动态显示 光学拍
k=k+1;
A=2*a*cos((k1-k2)/2*x-(w1-w2)/2*t);
v=a*cos(k1*x-w1*t)+a*cos(k2*x-w2*t);
plot(handles.axes4,x,v,'k-');
hold on;
plot(handles.axes4,x,A,'b:');
hold on;
plot(handles.axes4,x,-A,'r-.');
hold off;
%axis equal; %划定显示窗口范围
ylim(handles.axes4,[-3.4 3.4]);
xlim(handles.axes4,[0 10]);
xlabel(handles.axes4,'变量X');
ylabel(handles.axes4,'振幅变化'); %x处的波强
legend(handles.axes4,'合成波振幅','包络线','包络线');
m2(:,k)=getframe;
end
movie(m2,3);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
没有合适的资源?快使用搜索试试~ 我知道了~
【光学】基于matlab GUI两列单色平面波及其合成【含Matlab源码 4355期】.zip
共5个文件
png:2个
m:1个
jpg:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 37 浏览量
2024-04-27
08:19:22
上传
评论
收藏 301KB ZIP 举报
温馨提示
CSDN海神之光上传的全部代码均可运行,亲测可用,尽我所能,为你服务; 1、代码压缩包内容 主函数:main.m; 调用函数:其他m文件;无需运行 运行结果效果图; 2、代码运行版本 Matlab 2019b;若运行有误,根据提示修改;若不会,可私信博主; 3、运行操作步骤 步骤一:将所有文件放到Matlab的当前文件夹中; 步骤二:双击打开main.m文件; 步骤三:点击运行,等程序运行完得到结果; 4、物理应用 仿真:导航、地震、电磁、电路、电能、机械、工业控制、水位控制、直流电机、平面电磁波、管道瞬变流、刚度计算 光学:光栅、杨氏双缝、单缝、多缝、圆孔、矩孔衍射、夫琅禾费、干涉、拉盖尔高斯、光束、光波、涡旋 定位问题:chan、taylor、RSSI、music、卡尔曼滤波UWB 气动学:弹道、气体扩散、龙格库弹道 运动学:倒立摆、泊车 天体学:卫星轨道、姿态 船舶:控制、运动 电磁学:电场分布、电偶极子、永磁同步、变压器
资源推荐
资源详情
资源评论
收起资源包目录
【光学】基于matlab GUI两列单色平面波及其合成【含Matlab源码 4355期】.zip (5个子文件)
【光学】基于matlab GUI两列单色平面波及其合成【含Matlab源码 4355期】
main.m 6KB
1.png 11KB
运行结果.jpg 199KB
main.fig 78KB
2.png 57KB
共 5 条
- 1
资源评论
海神之光
- 粉丝: 5w+
- 资源: 6110
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功