Plot data import from excel to figure use GUI ?
이전 댓글 표시
Hello everyone!
I'm a beginer. and i want to study on GUI.
Now, i want to build a GUI such as: (see picture)
First, i want to click on "Import" button to import data from a excel file. And, i choise plot my data in "linear" or "dB", (1 dB = 20*log(x)), x is input data.
And, after i decided data in Y axes (vertical axes) is linear or dB depend on i click on "linear" or "Log". i will click on "draw" button to draw my data.
I wrote a code, but, it didn't run.
Please help me!
Thank you so much

This is my code: (i only show Callback functions)
function import_Callback(hObject, eventdata, handles)
handles.fileName = uigetfile('*.xlsx'); % imput mot file Excel
guidata(hObject,handles);
function draw_Callback(hObject, eventdata, handles)
filename = get(handles.import,'String');
values = xlsread(filename);
xCol = values(:,1);
yCol = values(:,2);
set(handles.truc,'Visible','on');
plot(handles.truc,xCol,yCol)
function linear_Callback(hObject, eventdata, handles)
set(handles.truc,'Scale','Linear');
function log_Callback(hObject, eventdata, handles)
set(handles.truc,'Scale','Log');
댓글 수: 4
Adam
2018년 12월 17일
What do you mean by 'It didn't run'? Do you get an error? If so what is the error? If not then what does happen? Nothing at all?
Adam
2018년 12월 17일
You need to get the YAxis from your axes and set 'Scale' on that. It isn't a property of the axes, at least not in recent versions of Matlab. You didn't include your version so I don't know which you are using.
e.g.
handles.truc.YAxis.Scale = 'Log'
or the equivalent for XAxis if you want the x axis logarithmic
Le Dung
2018년 12월 17일
Luna
2018년 12월 17일
Are you sure on that line values = xlsread(filename); filename is the full file name with its path like: 'C:\users\....\example1.xls' ?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
