Datatip, GUI screen and open Excel questions

조회 수: 6 (최근 30일)
Slobodan Djordjevi?
Slobodan Djordjevi? 2011년 11월 30일
Hello!
Can please someone help me with a simple qustions.
1) I have a plot in my GUI and I enabled Data Cursor. Because I have dates on my X, I converted it successfully. But now, I want to add a character(g) to the Y.
Y is a number(mass in grams), so I just want the datatip showing grams next to the mass value.
pos = get(event_obj,'Position');
output_txt = {['Datum: ',datestr(pos(1), 'dd.mmm.yyyy')],...
['Masa: ',num2str(pos(2))]};
2) When I run my GUI, I want it to be in the center of the screen. I used movegui(center), but it did nothing. Where should I even place the command in my GUI code?
3) I want my GUI to open an .xls file in Excel and not in Editor.
Slobodan

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 11월 30일
Hi,
for 2): what error do you get? You should add something like
movegui(handles.figure1, 'center')
for 3): do something like
[f,p] = uigetfile('*.xls');
winopen(fullfile(p,f))
Titus
  댓글 수: 2
Slobodan Djordjevi?
Slobodan Djordjevi? 2011년 11월 30일
Thanks man!
It worked!
2) But why is there a command movegui(center) and does not specify anything about handles?
3)When I click on PushButton, it opens the explorer asking me to choose a file. Can I get pass that, so it just directly opens up?
Titus Edelhofer
Titus Edelhofer 2011년 11월 30일
2) That's just like many other functions: if no handle is given, it takes the current figure (e.g. hold). More robust usually is to pass the handle.
3) Of course, if you know the file just write
winopen('C:\MyDatafile.xls')

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Titus Edelhofer
Titus Edelhofer 2011년 11월 30일
Hi,
for 1): do you mean this:
output_txt = {['Datum: ',datestr(pos(1), 'dd.mmm.yyyy')],...
['Masa: ',num2str(pos(2)) 'g']};
2) A call to movegui should come into your guiname_OpeningFcn.
3) Don't undertstand the question...
Titus

Slobodan Djordjevi?
Slobodan Djordjevi? 2011년 11월 30일
1) Worked like a charm!
2) I've put it in here, but it just pops ERROR.
% --- Executes just before goliGUI is made visible.
function goliGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% Choose default command line output for goliGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
plot(rand);
end
3) I want to open .xls file in Excel, outside MatLab on PushButton in my GUI. So when I click it, Excel 2007 opens and the file.
Thanks for a quick response!

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by