simple matlab GUI to display the plot and a count value

Hello,
I am working with reading the values form serial comport and I want to display the plot generated from the values fro every 1 sec or 2 sec. Aslo I want to display the value of count updating on the GUI. Can someone guide me with the building.
Thanks.

Answers (1)

For something like this you might not need more than a figure() with an axes() that is plotted into; perhaps with a text() or uicontrol('Style', 'text') object thrown in to display the count.

6 Comments

Yes, I was able to display value on the Plot but how to display the plot in 70 to 80% of the figure(1) space and other a small box with a title" value" above it and in the box showing the value(here the k value). The simple code used for displying value is
clear all;
for i=1:500:1500
for k=i:i+499
u(k)=k;
end;
figure(1),plot(u);
text(300,200,...
['Peakvalue = ',num2str(k)],...
'HorizontalAlignment','center',...
'BackgroundColor',[.7 .9 .7]);
pause (2);
end;
But how to make this into a small GUI as expalined above.
Thanks.
Can anyone help me out with this.
fignum = figure('Units', 'norm', 'Position', [.2 .2 .7 .7]); %part of screen
thisax = axes('Units', 'norm', 'Position', [0 0 .9 1]); %not full height
box1 = uicontrol('Style', 'text', 'Units', 'norm', 'Position', [.4 .9 .1 .09], 'String', 'Value');
box2 = uicontrol('Style', 'text', 'Units', 'norm', 'Position', [.51 .9 .2 .09]);
for i = 1 : 500 : 1500
for k = i : i + 499;
u(k) = k;
end
plot(u, 'Parent', thisax);
title(sprintf('Peakvalue = %f', k));
set(box2, 'string', sprintf('%f', k));
end
See Vincent's code here for an example of plotting more efficiently -- the part about updating XData and YData on existing line() or lineseries() objects instead of doing a complete plot()
Hi walter,
Sorry,for not explaning the thing I need clearly as I want to have a window showing a plot in the 70 to 80% of the window and the other smaller portion of the window showing box(which should be outside the plot and the one you demonstrated was displaying the peak value inside the plot) with title above it showing the peak value in the box.
The vincent code is a bit complicated for me to understand.As I want to start with a simpler one first. Thanks.
For thisax use [0 0 1 0.75]
I think I got the two box positions roughly right, but their width and relative positioning might need to be adjusted.
If you want one box to be above the other instead of to the left of the other, make sure the two have the same x coordinate instead of having the same y coordinate. The order goes [x, y, width, height]
If you don't want the title inside the plot at all, remove the title() call.

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products

Asked:

on 28 Nov 2013

Commented:

on 2 Dec 2013

Community Treasure Hunt

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

Start Hunting!