hi, i did GUI for image processing using matlab to see the running time. but i cannot show the running time in the gui, its only shown in the matlab command window. can anyone show me how to make it? please help me :(

 Accepted Answer

Try this in your pushbutton callback
startingTime = tic;
% some image processing code...
elapsedTime = toc(startingTime);
handles.edit1.String = sprintf('%.2f', elapsedTime);
Instead of edit1, use whatever you have for the "Tag" property of the edit box.

4 Comments

still doesn't work. this is some of my function.
tic
ticBytes(gcp);
J = 3;
a(1:N,1:M,1,1:J+1) = 0;
dx(1:N,1:M,1,1:J+1) = 0;
dy(1:N,1:M,1,1:J+1) = 0;
d(1:N,1:M,1,1:J+1) = 0;
tocBytes(gcp)
toc
it appear time for me in command window. but i cannot make it appear in my GUI that i have make. i want to show the time taken to user through GUI, not command window. :(
You keep doing the same thing and totally ignoring what people suggest.
The toc function has an output. Assign it to a variable as is shown in both answers.
sorry i'm not ignoring what you guys suggest. i have tried it before i'm replying here but i still didn't get what i want it to be. sorry again and for your information, i'm not major in this course so i'm not really understand about all the suggestions, but I had google and search about it before. It's okay then. Thank you for all the suggestions. I'll try again. :)
Look at my code again. It gets the elapsed time and sends it to your edit text box.
startingTime = tic;
% some image processing code...
J = 3;
a(1:N,1:M,1,1:J+1) = 0;
dx(1:N,1:M,1,1:J+1) = 0;
dy(1:N,1:M,1,1:J+1) = 0;
d(1:N,1:M,1,1:J+1) = 0;
elapsedTime = toc(startingTime);
handles.edit1.String = sprintf('%.2f', elapsedTime);

Sign in to comment.

More Answers (1)

Try tic and toc.

4 Comments

yes i used tic and toc in my function. it showed me the time, but it was in command window. but i want that time showing im my GUI, not command window
Then you need to capture the output from toc...
t = tic;
% do stuff
sec = toc(t);
The output from toc is the number of seconds since you called tic. No output is displayed in the command window.
I used this:
tic
ticBytes(gcp);
tocBytes(gcp)
toc
because i'm using parfor.
and this is the results it showed me in command window:
BytesSentToWorkers BytesReceivedFromWorkers
__________________ ________________________
Total 0 0
Elapsed time is 17.192636 seconds.
But, i want this "17.192636 seconds" appear in my GUI. :)
Just put the output from toc it into your edit box string, using num2str, in that case, although I would advise using a text control instead as an edit box is editable which does not make sense if it is reporting run time.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!