huxuemin2008 发表于 2009-1-8 16:46

如何用button读取计算机任意的txt文件然后,然后利用一定的函数关系在axes中画图

做毕业设计中遇到了这个问题,请大家多多指教

ch_j1985 发表于 2009-1-8 23:26

回复 楼主 huxuemin2008 的帖子

读取txt文件,论坛有精华帖
GUI界面论坛也有,LZ搜索一下

huxuemin2008 发表于 2009-1-10 20:59

谢谢,楼上的,我在精华区看过了,可自己的程序还是不能运行,这是我编的,麻烦大家帮忙看一下
=uigetfile({'*.txt','txt files(*.txt)';...
    '*.xls','excel files(*.xls)';'*.*','allfiles(*.*'},'读取数据');
L=length(fileName);
if L<5
    errodlg('文件错误','打开文件错误');
    return;
end
test=FileName(1,L-3:L);
switch test
    case'.txt'
      str=;
      x=load(str)
    case'.xls'
      str=;
      =xlsread(str);
      handles.shuju=shuju;
   otherwise   
    msgbox('文件错误','打开文件错误');
    return;

ChaChing 发表于 2009-1-10 22:13

回复 板凳 huxuemin2008 的帖子

LZ的程序自己编的吗? 好像与标题不太相同!
错误很多! 大小写不一致...

huxuemin2008 发表于 2009-1-12 10:48

是我自己编的参考了一些资料,我把变量的名字给能混了

huxuemin2008 发表于 2009-1-14 09:30

我的问题解决了和大家分享一下
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global x
=uigetfile('*.txt','please input');
st=;
x=load(st)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdatareserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
globalx
width=1200:400:4000;%x
depth=1200:400:3600;%y
height=x;
wi=1200:50:4000;
di=1200:50:3600;
di=di';
zcubic=interp2(width,depth,height,wi,di,'cubic');
%在二维上标注等高线
=contour(wi,di,zcubic);
clabel(C,H)
xlabel('Width')
ylabel('Depth')
title('在二维上标注等高线');
axes(handles.axes1)
页: [1]
查看完整版本: 如何用button读取计算机任意的txt文件然后,然后利用一定的函数关系在axes中画图