how to store values of a variable in array and store the array in a file in gui

조회 수: 2 (최근 30일)
puja dutta
puja dutta 2014년 6월 20일
편집: Joseph Cheng 2014년 6월 20일
here is my code function Keyup_set
x1=0; x2=0; x3=0; f=0;
h = figure;
set(h,'KeyPressFcn',@KeyDownCb,'KeyReleaseFcn',@KeyUpCb)
tic;
function KeyDownCb(~,evnt)
out = sprintf('Key: %s\n',evnt.Key);
disp(out)
x1=toc;
f=x1-x2;
disp(f)
end
function KeyUpCb(~,evnt)
x2=toc;
x3=(x2-x1);
disp(x3)
end
end
i have implemented this code in gui.Everytime i run this code, i need 9 values of f and x3.and i want to store all values of f and x3 in a array and store the array in a file using gui(using pushbutton how can store the array in file) .please help me

답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 6월 20일
you will need to call the function save() in the pushbutton callback. The documentation for save() will give you a good explanation of how to do this.
  댓글 수: 2
puja dutta
puja dutta 2014년 6월 20일
편집: puja dutta 2014년 6월 20일
i tried but i am not gettin.i used
savefile='puja.mat';
save(savefile,'handles.f')
in pushbutton but it shows error
handles.f is not a variable name
Joseph Cheng
Joseph Cheng 2014년 6월 20일
편집: Joseph Cheng 2014년 6월 20일
when you put a break point before the save does handles.f exist?
if not when you create handles.f you will need to call guidata(hObject, handles); at the end of the function (before it goes back to the main gui section) to update the handles object.
or... possibly that maynot work... i just noticed that you're not using guide.

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by