内容字号:默认大号超大号

段落设置:段首缩进取消段首缩进

字体设置:切换到微软雅黑切换到宋体

奇幻城国际娱乐

2018-12-06 出处:网络 整理:sesligaranti.com

    话题:怎样用matlab编写双缝干涉的GUI界面

    回答:function varargout = gui_light_13_9(varargin)% GUI_LIGHT_13_9 M-file for gui_light_13_9.fig% GUI_LIGHT_13_9, by itself, creates a new GUI_LIGHT_13_9 or raises the existing% singleton*.%% H = GUI_LIGHT_13_9 returns the handle to a new GUI_LIGHT_13_9 or the handle to% the existing singleton*.%% GUI_LIGHT_13_9('CALLBACK',hObject,eventData,handles,) calls the local% function named CALLBACK in GUI_LIGHT_13_9.M with the given input arguments.%% GUI_LIGHT_13_9('Property','Value',) creates a new GUI_LIGHT_13_9 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before gui_light_13_9_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to gui_light_13_9_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 gui_light_13_9% Last Modified by GUIDE v2.5 08-Sep-2007 17:51:39% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, 'gui_Singleton', gui_Singleton, 'gui_OpeningFcn', @gui_light_13_9_OpeningFcn, 'gui_OutputFcn', @gui_light_13_9_OutputFcn, 'gui_LayoutFcn', [] , 'gui_Callback', []);if nargin ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 gui_light_13_9 is made visible.function gui_light_13_9_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 gui_light_13_9 (see VARARGIN)% Choose default command line output for gui_light_13_9set(handles.lambda_edit,'String',0.0000006);set(handles.d_edit,'String',0.0015);set(handles.z_edit,'String',2);handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_light_13_9 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_light_13_9_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 structurevarargout{1} = handles.output;% --- Executes on button press in light_pushbutton.function light_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to light_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)Lambda=str2num(get(handles.lambda_edit,'String'));d=str2num(get(handles.d_edit,'String'));z=str2num(get(handles.z_edit,'String'));yMax=5*Lambda*z/d;xs=yMax;Ny=101;ys=linspace(-yMax,yMax,Ny);for i=1:Ny L1=sqrt((ys(i)-d/2).^2+z.^2); L2=sqrt((ys(i)+d/2).^2+z.^2); Phi=2*pi*(L2-L1)/Lambda; B(i,:)=4*cos(Phi/2).^2;endNCL=255;%确定所用灰度等级为255级Br=(B/4.0)*NCL;%定标,使最大光强(4.0)定为最大灰度级(白色)axes(handles.axes1)image(xs,ys,Br);colormap(gray(NCL));xlabel('双缝干涉条纹')axes(handles.axes2)plot(B(:),ys);xlabel('双缝干涉光强分布')% --- Executes on button press in close_pushbutton.function close_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to close_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)closefunction lambda_edit_Callback(hObject, eventdata, handles)% hObject handle to lambda_edit (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 lambda_edit as text% str2double(get(hObject,'String')) returns contents of lambda_edit as a double% --- Executes during object creation, after setting all properties.function lambda_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to lambda_edit (see GCBO)%

    参考回答:clear lam=500e-9;%λ=lama=2e-3;D=1;%变量a,Dym=5*lam*D/a;xs=ym;n=101;ys=linspace(-ym,ym,n);%在范围之间产生n个数据for i=1:nr1=sqrt((ys(i)-a/2).^2+D^2);%r1表达式的matlab书写形式r2=sqrt((ys(i)+a/2).^2+D^2);%r2表达式的matlab书写形式 phi=2*pi*(r2-r1)./lam;%);%);%Φ表达式的matlab书写形式 B(i,:)=sum(4*cos(phi/2).^2);%光强的matlab书写形式endN=0;Br=(B/4.0)*N;subplot(1,2,1)%把图形画在1行2列图像中的第一幅图中,image(xs,ys,Br);%画图函数colormap(gray(N));%控制颜色subplot(1,2,2)%把图形画在1行2列图像中的第二幅图中,plot(B,ys) ;%画图函数怎样用matlab编写双缝干涉的GUI界面

    话题:matlab中的GUI界面编程,在界面中输入一个数据,按下按钮根据公

    回答:在按钮的callback里用get语句取得输入的变量,然后编写计算公式,再用set语句将求得的结果显示在想要显示的地方就行了~~~

    参考回答:这个简单吧。你去看一于句柄的奇幻城国际娱乐,然后编写回调函数就很容易实现

    话题:怎样用matlab编写双缝干涉的GUI界面

    回答:%% GUI_LIGHT_13_9('gui_OpeningFcn'..;Property', handles, varargin)% This function has no output args..;,2). Starting from the left, property value pairs are% applied to the GUI before gui_light_13_9_OpeningFunction gets called, by itself, creates a new GUI_LIGHT_13_9 or raises the existing% singleton*.%% H = GUI_LIGHT_13_9 returns the handle to a new GUI_LIGHT_13_9 or the handle to% the existing singleton*function varargout = gui_light_13_9(varargin)% GUI_LIGHT_13_9 M-file for gui_light_13_9.fig% GUI_LIGHT_13_9,hObject, , varargin{:});handles,'String',., varargin{:}),0. 'end% End initialization code - DO NOT EDIT% --- Executes just before gui_light_13_9 is made visible,eventData;,0.0015);set(handles.z_edit, []);if nargin ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}).. 'gui_Singleton','String'.. 'gui_LayoutFcn';gui_State = struct('CALLBACK',.;String';gui_Callback', GUIDATA, GUIHANDLES% Edit the above text to modify the response to help gui_light_13_9% Last Modified by GUIDE v2.5 08-Sep-2007 17:nargout}] = gui_mainfcn(gui_State;.%% See also: GUIDE.0000006);set(handles.d_edit..) calls the local% function named CALLBACK in GUI_LIGHT_13_9.M with the given input arguments, , 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 gui_light_13_9 (see VARARGIN)% Choose default command line output for gui_light_13_9set(handles.lambda_edit,'..,handles..) creates a new GUI_LIGHT_13_9 or raises the% existing singleton*, @gui_light_13_9_OpeningFcn.function gui_light_13_9_OpeningFcn(hObject, eventdata, . An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to gui_light_13_9_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. ', @gui_light_13_9_OutputFcn, .;else gui_mainfcn(gui_State;endif nargout [varargout{1,'Value':51:39% Begin initialization code - DO NOT EDITgui_Singleton = 1. 'gui_Name'. Choose "GUI allows only one% instance to run (singleton)quot, [] , gui_Singleton;gui_OutputFcn', mfilename, ..%% GUI_LIGHT_13_9('.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_light_13_9 wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_light_13_9_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 structurevarargout{1} = handles.output;% --- Executes on button press in light_pushbutton.function light_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to light_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)Lambda=str2num(get(handles.lambda_edit,'String'));d=str2num(get(handles.d_edit,'String'));z=str2num(get(handles.z_edit,'String'));yMax=5*Lambda*z/d;xs=yMax;Ny=101;ys=linspace(-yMax,yMax,Ny);for i=1:Ny L1=sqrt((ys(i)-d/2).^2+z.^2); L2=sqrt((ys(i)+d/2).^2+z.^2); Phi=2*pi*(L2-L1)/Lambda; B(i,:)=4*cos(Phi/2).^2;endNCL=255;%确定所用灰度等级为255级Br=(B/4.0)*NCL;%定标,使最大光强(4.0)定为最大灰度级(白色)axes(handles.axes1)image(xs,ys,Br);colormap(gray(NCL));xlabel('双缝干涉条纹')axes(handles.axes2)plot(B(:),ys);xlabel('双缝干涉光强分布')% --- Executes on button press in close_pushbutton.function close_pushbutton_Callback(hObject, eventdata, handles)% hObject handle to close_pushbutton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)closefunction lambda_edit_Callback(hObject, eventdata, handles)% hObject handle to lambda_edit (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 lambda_edit as text% str2double(get(hObject,'String')) returns contents of lambda_edit as a double% --- Executes during object creation, after setting all properties.function lambda_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to lambda_edit (see GCBO)% eventdata

    参考回答:ym,n):nr1=sqrt((ys(i)-a/,Dym=5*lam*D/a;%λ=lama=2e-3;D=1;%变量a;lam;2).^2+D^2);%r1表达式的matlab书写形式r2=sqrt((ys(i)+a/2),ys,Br);%画图函数colormap(gray(N));n=101;ys=linspace(-ym;%Φ表达式的matlab书写形式 B(i,;%在范围之间产生n个数据for i=1;4.^2+D^2);%控制颜色subplot(1,2,2)%把图形画在1行2列图像中的第二幅图中,plot(B;Br=(B/%r2表达式的matlab书写形式 phi=2*pi*(r2-r1)./%);%):)=sum(4*cos(phi/2).^2);%光强的matlab书写形式endN=0.0)*N;subplot(1,2,1)%把图形画在1行2列图像中的第一幅图中,image(xsclear lam=500e-9;xs=ym

    话题:在MATLAB中设计一个简单的GUI界面 要调用的程序我写好了

    回答:1、设计GUI,应该说明一下要求,界面上有哪些要素、可进行哪些作;2、函数cacupsnr好像并不是MATLAB自带的。怎样用matlab编写双缝干涉的GUI界面

    话题:MATLAB中的GUI编程怎么将数值从一个界面传递到另一个界面来显示

    回答:举例:a = 1;setappdata(0,a)另一个界面上value = getappdata(0,a)还可以用global来定义这个要传的变量。1,GUI与早期计算机使用的命令行界面相比,图形界面对于来说在视觉上更易于接受。2,GUI界面若要通过在显示屏的特置,以”各种美观而不单调的视觉“提示”状态的改变“,势必得比简单的呈现花上的计算能力。3,图形界面允使用鼠标等输入设备纵屏幕上的图标或菜单选项,以选择命令、调用、启动程序或执行其它一些日常任务。4,GUI的广泛应用是当今计算机发展的成就之一,它极大地方便了非专业的使用。人们从此不再需要记硬背大量的命令,取而之的是可以通过窗口、菜单、按键等方式来方便地进行作。

    话题:MATLAB GUI中一个界面,并实现数据传递功能

    回答:你的问题我今天刚刚解决,可能有点复杂哈,不过很好懂。假设你有一个GUIgui_1,另一个gui_2,在gui_2中调用gui_1的参数或者结果,在gui_2中uttonCallback下输入function pushbutton1_Callback(hObject, eventdata, handles)a=gui_1;..则gui_1的结果就传递到a中。现在再说gui_1中的参数输入,(1)返回值只有一个的情况在gui_1中的:function gui_1_OpeningFcn(hObject, eventdata, handles, varargin)下面任意一个地方输入handles.output = 数据或者变量名;在gui_1中的function varargout = untitled_OutputFcn(hObject, eventdata, handles)varargout{1} = handles.output;其实程序本来的.m就是这样的,不用更改,如果数据或者变量是在同一个GUI中别的控件或执行中输入的,将数据或者变量名定义为全变量就可global 数据或者变量名;同时在function gui_1_OpeningFcn(hObject, eventdata, handles, varargin)第一句就输入global 数据或者变量名;再输入handles.output = 数据或者变量名;即可。(2)返回值有多个以上的情况基本以上面相同,function gui_1_OpeningFcn(hObject, eventdata, handles, varargin)下面任意一个地方输入handles.output = 数据1或者变量名1;handles.secend_output = 数据2或者变量名2;handles.thrid_output = 数据3或者变量名3;同时在在gui_1中OutputFcn输入以下语句function varargout = gui_1_OutputFcn(hObject, eventdata, handles)varargout{1} = handles.output;varargout{2} = handles.secend_output;varargout{3} = handles.thrid_output;依次类推,在同一个gui中的参数传递采用上述的设置为全变量调用即可。同时对返回值为多参数的情况gui_2中则要输入语句改为在gui_2中uttonCallback下输入function pushbutton1_Callback(hObject, eventdata, handles)[data1,data2,data3,.]=gui_1;..则gui_1的结果就传递到[data1,data2,data3,.]=中,分别对这些返回值进行作即可。按照以上的做法,可能很复杂,可是对于初一看就明白,我也是刚刚才开始学,不知对你有帮助没。

    参考回答:在主界面程序设置一个global data,在新打开的界面中设置global data,再使用,看看能不能传递过去.

    话题:如何用matlab编程实现一组数据的曲线拟合

    回答:x=[1;1.5;2;2.5;3]; y=[0.9;1.7;2.2;2.6;3]; p=fittype('a*x.^0.5+b*lnx+c','independent','x') f=fit(x,y,p) plot(f,x,y); 上面是码! 下面是结果: a=2.818 b=0.8552 c=-0.6627

    话题:用matlab编写一个gui程序,程序能够打开一个图片,并将图片显示

    回答:可以使用I=read('图片.bmp');imshow(I);来完成你要求的功能,要放在你的编写的.m的目录中。如果图片不在你编写的.m的目录中,则需要用I=read('图片路径\图片.bmp');imshow(I);如果想在坐标系内显示图片,只需要在显示

    参考回答:展开全部 可以使用I=read('图片.bmp');imshow(I);来完成你要求的功能,要放在你的编写的.m的目录中。如果图片不在你编写的.m的目录中,则需要用I=read('图片路径\图片.bmp');imshow(I);如果想在坐标系内显示图片,只需要在显示图片的语句前加上坐标系 即:可以使用I=read('图片.bmp');axes(handles.axes); %handles.axes为坐标系句柄,请根据你GUI上的坐标系组件Tag输入句柄imshow(I);

    话题:怎么用MATLAB做一个串口?是先做一个GUI界面,再对应的编写程序

    回答:那你只要给检测按钮加好callback函数就行了啊。你可以直接用GUIDE做。

    参考回答:需要gui就做gui, 不需要就不做, 这跟串口有什么?怎样用matlab编写双缝干涉的GUI界面

    话题:Matlab编写GUI程序实现一个pid控制系统的控制,这个程序能否使用

    回答:你的Simulink模型直接与外部物理系统连接进行控制,用的是External模式?原则上,任何通过GUI可以实现的Simulink作,都可以通过MATLAB程序实现,所需的在Simulink手册中应该都可以找到。例如,打开模型用open_system,运行或停止用类似下面的命令:set('sys', 'SimulationCommand', 'start');其中 sys 是模型名。注意不能使用 sim 函数,因为后者的过程是不可干预的。

分享给小伙伴们:

相关文章

搞笑图片