界面:
代码:
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)
%代码编写
[FileName,PathName] = uigetfile('*.txt','select the Date file'); %获取文件名和路径
file = fullfile(PathName,FileName);
data = load(file); %读取文件
axes(handles.axes1);
%将TXT文件的第一二列作为横纵坐标绘图
x = data(:,1);
y = data(:,2);
%绘制图像
plot(x,y);
xlabel('时间(s)'); %横坐标标题
ylabel('压力(MPa)'); %纵坐标标题
grid on
hold on
%实现图像可以像simulink里一样缩放大小
zoom on
===========================================
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)
%代码编写
[FileName,PathName] = uigetfile('*.txt','select the Date file'); %获取文件名和路径
file1 = fullfile(PathName,FileName);
data1 = load(file1); %读取文件
axes(handles.axes1);
%将TXT文件的第一二列作为横纵坐标绘图
a = data1(:,1);
b = data1(:,2);
%绘制图像
plot(a,b);
grid on
hold on
%实现图像可以像simulink里一样缩放大小
zoom on
=====================================
新建2个text文件:
text1的内容:
text2的内容:
运行后的效果:
|
请发表评论