可以使用
I=read('bmp');
imshow(I);
来完成你要求的功能,文件要放在你的编写的m文件的目录中。
如果不在你编写的m文件的目录中,则需要用
I=read('路径\bmp');
imshow(I);
如果想在坐标系内显示,只需要在显示的语句前加上坐标系 即:
可以使用
I=read('bmp');
axes(handlesaxes); %handlesaxes为坐标系句柄,请根据你GUI上的坐标系组件Tag输入句柄
imshow(I);
(1)首先,char函数解决不了您的问题。
char()在这里是强制类型转化,将ASCII表中对应数值的字符进行显示。
设Z=4823,则char(z)将显示0,函数将z取整后的值进行对应,字符'0'的ASCII码为48
(2)其次,可以采用num2str(z)达到目标效果。
具体可以尝试搜索各种数据类型的相互转换方法,会有更多收获的。
设z=4823,则num2str(z)将返回4823
希望对你有所帮助!
function varargout = gui_light_13_9(varargin)
% GUI_LIGHT_13_9 M-file for gui_light_13_9fig
% 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_9M 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 v25 08-Sep-2007 17:51:39
% Begin initialization code - DO NOT EDIT
gui_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_Stategui_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 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_9
set(handleslambda_edit,'String',00000006);
set(handlesd_edit,'String',00015);
set(handlesz_edit,'String',2);
handlesoutput = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes gui_light_13_9 wait for user response (see UIRESUME)
% uiwait(handlesfigure1);
% --- 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 structure
varargout{1} = handlesoutput;
% --- 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(handleslambda_edit,'String'));
d=str2num(get(handlesd_edit,'String'));
z=str2num(get(handlesz_edit,'String'));
yMax=5Lambdaz/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=2pi(L2-L1)/Lambda;
B(i,:)=4cos(Phi/2)^2;
end
NCL=255;%确定所用灰度等级为255级
Br=(B/40)NCL;%定标,使最大光强(40)定为最大灰度级(白色)
axes(handlesaxes1)
image(xs,ys,Br);
colormap(gray(NCL));
xlabel('双缝干涉条纹')
axes(handlesaxes2)
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)
close
function 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 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
function d_edit_Callback(hObject, eventdata, handles)
% hObject handle to d_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 d_edit as text
% str2double(get(hObject,'String')) returns contents of d_edit as a double
% --- Executes during object creation, after setting all properties
function d_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to d_edit (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
function z_edit_Callback(hObject, eventdata, handles)
% hObject handle to z_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 z_edit as text
% str2double(get(hObject,'String')) returns contents of z_edit as a double
% --- Executes during object creation, after setting all properties
function z_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to z_edit (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
% --------------------------------------------------------------------
function light_menu_Callback(hObject, eventdata, handles)
% hObject handle to light_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
light_pushbutton_Callback(hObject, eventdata, handles)
% --------------------------------------------------------------------
function close_menu_Callback(hObject, eventdata, handles)
% hObject handle to close_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close
% --------------------------------------------------------------------
function file_menu_Callback(hObject, eventdata, handles)
% hObject handle to file_menu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
这个太简单了,马上给分吧
axes(handlesaxes2)(如果你采用的是axes1,就把2改成1,这个懂吧?)
plot( );
plot里面要写你要画的那个函数的参数值。
不懂再问我。 我当年用GUI做了一个EXE软件哈
你点击看下你那个axes的tag属性,看是axes后面的数字,看是多少就写多少呗,1就写1,2就写2嘛。
你新建一个button,然后,在button下面写代码呢。不要在那个axes下面写。
我之所以对这种用GUIDE方式创建GUI时的图形尺寸、位置控制感兴趣,是因为看到别人在用代码创建GUI时可以精确控制窗口的位置、尺寸,以及各控件的位置和尺寸,包括边界线的属性,也就是定义这些对象的各种属性。比如,通过get(0,'ScreenSzie')来获取电脑屏幕尺寸,包含左、底、宽、高,单位貌似是像素吧,宽高就是电脑的分辨率。然后通过对figure命令中的position属性赋值设置运行界面的位置和大小,此时参考前面获取的那些位置和尺寸,那么就可以对运行界面实现定位和定大小了。但是觉得那种方式太繁琐了,所以探究下这种方式下怎样利用设计界面的标尺等工具来精确定位和定大小。希望能碰到可以指点的筒子。 查看更多答案>>
之前实现了在figure上把做为背景,现在实现在Guide上实现。\x0d\其实很简单,就是在Fcn的地方添加以下代码:\x0d\\x0d\ha=axes('units','normalized','position',[0 0 1 1]);\x0d\uistack(ha,'down')\x0d\II=imread('禾木01bmp');\x0d\image(II)\x0d\colormap gray\x0d\set(ha,'handlevisibility','off','visible','off');\x0d\\x0d\另外如果要把那些按钮等的背景也改变,也是在此处添加相应代码就可。\x0d\比如下面代码把按钮的背景改变了(此方法已有人在论坛发过帖子,请自己搜索):\x0d\I=imread('buttoncdatabmp');\x0d\set(handlespushbutton1,'cdata',I);
function [] = zsl_1209_a()
Sfh = figure('units','pixels',
'position',[450 450 400 200],
'menubar','none',
'name','Verify Password',
'resize','off',
'numbertitle','off',
'name','GUI_25');
Sed1 = uicontrol('style','edit',
'units','pix',
'position',[20 140 100 40],
'backgroundcolor','w',
'HorizontalAlign','center',
'string','分母',
'fontsize',14,'fontweight','bold');
Sed2 = uicontrol('style','edit',
'units','pix',
'position',[20 80 100 40],
'backgroundcolor','w',
'HorizontalAlign','center',
'string','分子',
'fontsize',14,'fontweight','bold');
Sed3 = uicontrol('style','edit',
'units','pix',
'position',[200 100 100 60],
'backgroundcolor','w',
'HorizontalAlign','center',
'string','结果',
'fontsize',14,'fontweight','bold');
Spb = uicontrol('style','push',
'units','pix',
'position',[10 10 380 40],
'backgroundcolor','w',
'HorizontalAlign','left',
'string','计算',
'fontsize',14,'fontweight','bold',
'callback',{@pb_call,S});
function [] = pb_call(varargin)
S = varargin{3}; % Get the structure
fenmu=get(Sed1,'string');
fenmu=str2num(fenmu);
fenzi=get(Sed2,'string');
fenzi=str2num(fenzi);
jieguo=fenmu/fenzi;
set(Sed3,'string',num2str(jieguo));
欢迎分享,转载请注明来源:表白网
评论列表(0条)