matlab打开用什么程序出错,我有一个matlab的程序运行出错,各位大神求救,很急啊...

这是一个基于MATLAB的牛顿环等厚干涉仿真程序,用户可以通过调整波长、曲率半径、介质薄膜厚度和折射率等参数,实时观察干涉图像的变化。程序还提供了光强分布和关闭功能,以及打开原理介绍的PPT和数据处理子程序。此外,用户可以进行模拟测量并保存数据。
摘要由CSDN通过智能技术生成

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

function varargout = Newton_Ring(varargin)% NEWTON_RING M-file for Newton_Ring.fig% NEWTON_RING, by itself, creates a new NEWTON_RING or raises the existing% singleton*.%% H = NEWTON_RING returns the handle to a new NEWTON_RING or the handle to% the existing singleton*.%% NEWTON_RING('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in NEWTON_RING.M with the given input arguments.%% NEWTON_RING('Property','Value',...) creates a new NEWTON_RING or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before Newton_Ring_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to Newton_Ring_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 Newton_Ring

% Last Modified by GUIDE v2.5 08-Apr-2012 20:24:08

% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Newton_Ring_OpeningFcn, ... 'gui_OutputFcn', @Newton_Ring_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 Newton_Ring is made visible.function Newton_Ring_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 Newton_Ring (see VARARGIN)movegui(gcf, 'center');set(gcf,'outerposition',get(0,'screensize'));

guangpu0=double(imread ('F:\桌面资料\论文\牛顿环最新GUI程序\光谱.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000;%厚度层 nm n=get(handles.zheshelv,'value'); %折射率

k=round((L-359)*900/400.5)-1; % 可见光中心波长范围360-760(紫-> 红)yanse=guangpu(:,k) ;L=L/1000000000;[x,y] = meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2 =(x.^2+y.^2) ;derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2;I=(2+2*cos(2*derta*pi./L))/4;Ic(:,:,1) = I*yanse(1); %存R值Ic(:,:,2) = I*yanse(2); %存G值Ic(:,:,3) = I*yanse(3); %存B值Icmax =max(max(max(Ic)));axes(handles.axes2);image(Ic/Icmax) %显示出仿真图像axis off

% Choose default command line output for Newton_Ringhandles.output = hObject;

% Update handles structureguidata(hObject, handles);

% UIWAIT makes Newton_Ring wait for user response (see UIRESUME)% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.function varargout = Newton_Ring_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 guangqiangfenbu.function guangqiangfenbu_Callback(hObject, eventdata, handles)% hObject handle to guangqiangfenbu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)h=figure('Color',[1 1 1]);L=get(handles.bochang,'value');R=get(handles.qiumianqulv,'value');d=get(handles.kongqicenghoudu,'value')*10000;n=get(handles.zheshelv,'value');

[x,y]=meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2=(x.^2+y.^2);

h = R-sqrt(R^2-r2);%干涉的高度Di=[L/2+2*n*h*1e9]/L;In=(cos(Di*pi)).^2;%相位差的余弦

mesh(x,y,In)shading interpview(-40,70)title('光强分布','fontsize',20,'fontname','华文新魏')

% --- Executes on button press in donghuayanshi.function donghuayanshi_Callback(hObject, eventdata, handles)% hObject handle to donghuayanshi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

guangpu0=double(imread ('guangpu.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000; %厚度层 nm n=get(handles.zheshelv,'value'); %折射率 [x,y]=meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2=(x.^2+y.^2);

for L = 360:1:758; %L的改变 k=round((L-359)*900/401)-1; % 可见光中心波长范围360-760(紫-> 红) yanse=guangpu(:,k) ; L=L/1000000000; derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2; I=(2+2*cos(2*derta*pi./L))/4; Ic(:,:,1) = I*yanse(1); %存R值 Ic(:,:,2) = I*yanse(2); %存G值 Ic(:,:,3) = I*yanse(3); %存B值 Icmax =max(max(max(Ic))); axes(handles.axes2); image(Ic/Icmax) %显示出仿真图像 axis off set(handles.bochangtext,'string',['波长: ',num2str(L*1000000000),'nm']); set(handles.bochang,'value',L*1000000000);end

% --- Executes on button press in close.function close_Callback(hObject, eventdata, handles)% hObject handle to close (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close

% --- Executes on button press in yuanli.function yuanli_Callback(hObject, eventdata, handles)% hObject handle to yuanli (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)winopen('牛顿环等厚干涉原理.ppt')

% --- Executes on button press in shujuchuli.function shujuchuli_Callback(hObject, eventdata, handles)% hObject handle to shujuchuli (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)run NowtonRing_shujuchuli;

% --- Executes on slider movement.function bochang_Callback(hObject, eventdata, handles)% hObject handle to bochang (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderguangpu0=double(imread ('guangpu.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000;%厚度层 nm n=get(handles.zheshelv,'value'); %折射率

k=round((L-359)*900/400.5)-1; % 可见光中心波长范围360-760(紫-> 红)yanse=guangpu(:,k) ;L=L/1000000000;[x,y] = meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2 =(x.^2+y.^2) ;derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2;I=(2+2*cos(2*derta*pi./L))/4;Ic(:,:,1) = I*yanse(1); %存R值Ic(:,:,2) = I*yanse(2); %存G值Ic(:,:,3) = I*yanse(3); %存B值Icmax =max(max(max(Ic)));axes(handles.axes2);image(Ic/Icmax) %显示出仿真图像axis off

set(handles.bochangtext,'string',['波长λ: ',num2str(L*1000000000),'nm']);

% --- Executes during object creation, after setting all properties.function bochang_CreateFcn(hObject, eventdata, handles)% hObject handle to bochang (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

% --- Executes on slider movement.function kongqicenghoudu_Callback(hObject, eventdata, handles)% hObject handle to kongqicenghoudu (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderguangpu0=double(imread ('guangpu.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000;%厚度层 nm n=get(handles.zheshelv,'value'); %折射率

k=round((L-359)*900/400.5)-1; % 可见光中心波长范围360-760(紫-> 红)yanse=guangpu(:,k) ;L=L/1000000000;[x,y] = meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2 =(x.^2+y.^2) ;derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2;I=(2+2*cos(2*derta*pi./L))/4;Ic(:,:,1) = I*yanse(1); %存R值Ic(:,:,2) = I*yanse(2); %存G值Ic(:,:,3) = I*yanse(3); %存B值Icmax =max(max(max(Ic)));axes(handles.axes2);image(Ic/Icmax) %显示出仿真图像axis off

set(handles.kongqicenghoudutext,'string',['介质薄膜厚度d: ',num2str(d*10000000),'nm']);

% --- Executes during object creation, after setting all properties.function kongqicenghoudu_CreateFcn(hObject, eventdata, handles)% hObject handle to kongqicenghoudu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

% --- Executes on slider movement.function qiumianqulv_Callback(hObject, eventdata, handles)% hObject handle to qiumianqulv (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderguangpu0=double(imread ('guangpu.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000;%厚度层 nm n=get(handles.zheshelv,'value'); %折射率

k=round((L-359)*900/400.5)-1; % 可见光中心波长范围360-760(紫-> 红)yanse=guangpu(:,k) ;L=L/1000000000;[x,y] = meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2 =(x.^2+y.^2) ;derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2;I=(2+2*cos(2*derta*pi./L))/4;Ic(:,:,1) = I*yanse(1); %存R值Ic(:,:,2) = I*yanse(2); %存G值Ic(:,:,3) = I*yanse(3); %存B值Icmax =max(max(max(Ic)));axes(handles.axes2);image(Ic/Icmax) %显示出仿真图像axis offset(handles.qumianqulvtext,'string',['曲率半径 :',num2str(R),'m']);

% --- Executes during object creation, after setting all properties.function qiumianqulv_CreateFcn(hObject, eventdata, handles)% hObject handle to qiumianqulv (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

% --- Executes on slider movement.function zheshelv_Callback(hObject, eventdata, handles)% hObject handle to jiezhizheshelv (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,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of sliderguangpu0=double(imread ('guangpu.jpg')); % 取光谱图数据,光谱数据为79×371×3)guangpu=[guangpu0(1,:,1); guangpu0(1,:,2); guangpu0(1,:,3)];%确定牛顿环的内部参数,在计算处理时候用m作为单位L=get(handles.bochang,'value'); %波长 nmR=get(handles.qiumianqulv,'value'); %半径 m d=get(handles.kongqicenghoudu,'value')/100000;%厚度层 nm n=get(handles.zheshelv,'value'); %折射率

k=round((L-359)*900/400.5)-1; % 可见光中心波长范围360-760(紫-> 红)yanse=guangpu(:,k) ;L=L/1000000000;[x,y] = meshgrid(linspace(-0.004,0.004,400)); %确定干涉的位置与范围r2 =(x.^2+y.^2) ;derta=2*d*n+(R-sqrt(R^2-r2))*2+L/2;I=(2+2*cos(2*derta*pi./L))/4;Ic(:,:,1) = I*yanse(1); %存R值Ic(:,:,2) = I*yanse(2); %存G值Ic(:,:,3) = I*yanse(3); %存B值Icmax =max(max(max(Ic)));axes(handles.axes2);image(Ic/Icmax) %显示出仿真图像axis offset(handles.zheshelvtext,'string',['介质折射率n:',num2str(n)]);

% --- Executes during object creation, after setting all properties.function zheshelv_CreateFcn(hObject, eventdata, handles)% hObject handle to jiezhizheshelv (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end

% --- Executes on mouse press over axes background.function axes2_ButtonDownFcn(hObject, eventdata, handles)

% --- Executes during object creation, after setting all properties.function axes2_CreateFcn(hObject, eventdata, handles)% hObject handle to axes2 (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 axes2

% --- Executes on button press in moniceliang.function moniceliang_Callback(hObject, eventdata, handles)% hObject handle to moniceliang (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)k=1;i=0;while k i=i+1; [x(i),y(i)]=ginput(1); set(handles.zuobiao,'string',['(',num2str(i),') ',' X坐标:',num2str(x(i)/49.8416),' mm']); s=get(gcf,'currentkey');%获取键盘操作信息 if strcmp(s,'space') %判断是否为space键 k=0; %k=0循环终止 end endfid=fopen('模拟测量数据.txt','wt');fprintf(fid,'%f ',x(1,1:i)/49.8416);fclose(fid);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值