声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1414|回复: 5

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

[复制链接]
发表于 2009-1-8 16:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
做毕业设计中遇到了这个问题,请大家多多指教
回复
分享到:

使用道具 举报

发表于 2009-1-8 23:26 | 显示全部楼层

回复 楼主 huxuemin2008 的帖子

读取txt文件,论坛有精华帖
GUI界面论坛也有,LZ搜索一下
 楼主| 发表于 2009-1-10 20:59 | 显示全部楼层
谢谢,楼上的,我在精华区看过了,可自己的程序还是不能运行,这是我编的,麻烦大家帮忙看一下
[filename,pathname]=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=[pathName filename];
        x=load(str)
    case'.xls'
        str=[pathName filename];
        [shu ju]=xlsread(str);
        handles.shuju=shuju;
   otherwise   
    msgbox('文件错误','打开文件错误');
    return;
发表于 2009-1-10 22:13 | 显示全部楼层

回复 板凳 huxuemin2008 的帖子

LZ的程序自己编的吗? 好像与标题不太相同!
错误很多! 大小写不一致...
 楼主| 发表于 2009-1-12 10:48 | 显示全部楼层
是我自己编的参考了一些资料,我把变量的名字给能混了
 楼主| 发表于 2009-1-14 09:30 | 显示全部楼层
我的问题解决了和大家分享一下
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)
global x
[filename path]=uigetfile('*.txt','please input');
st=[path filename];
x=load(st)
% --- 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)
global  x
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');
%在二维上标注等高线
[C,H]=contour(wi,di,zcubic);
clabel(C,H)
xlabel('Width')
ylabel('Depth')
title('在二维上标注等高线');
axes(handles.axes1)

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-18 06:57 , Processed in 0.048332 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表