如何在GUI Matlab中读取和绘制记事本数据

时间:2016-12-07 01:45:09

标签: matlab user-interface matlab-guide

我有3列记事本数据,我想绘制它,我已经完成了阅读但是当我绘制它们时它不起作用。也许错误就是把它作为专栏阅读,但我不知道如何做到这就是记事本数据:

x           y           z
4335554.03  9142298.37  161.09
4335556.17  9142302.03  156.82
4335556.67  9142315.09  154.00
4335560.58  9142316.57  154.69
4335568.68  9142308.81  154.12
4335573.75  9142306.00  154.60
4335597.23  9142291.80  155.23
4335585.35  9142293.23  153.69
4335563.85  9142262.00  164.81
4335527.84  9142303.28  162.81
4335552.00  9142322.25  151.90
4335556.60  9142324.86  152.46
4335567.70  9142325.68  153.60
4335573.84  9142344.56  153.70
4335580.60  9142345.14  155.92

这是我的GUI脚本:

% --- Executes on button press in Load.
function Load_Callback(hObject, eventdata, handles)
% hObject    handle to Load (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data
[filename pathname]=uigetfile({'*.txt'},'File Selector');
fileID = fopen(strcat(pathname, filename),'r'); % read-only permission
handles.fileData = fscanf(fileID,'%d');
guidata(hObject, handles);
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname);
set(handles.text1,'string',fullpathname)
set(handles.text2,'string',text)



% --- Executes on button press in Start.
function Start_Callback(hObject, eventdata, handles)
% hObject    handle to Start (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global data
x = handles.fileData(:,1)
y = handles.fileData(:,2)
z = handles.fileData(:,3)
contour (x,y,z)
axes(handles.panel);

我无法弄清楚,y = handles.fileData(:,2)

总是出错

0 个答案:

没有答案