How can I change the color of a circle according to a changing variable?

8 次查看(过去 30 天)
For my thesis I will calculate a certain parameter in real-time. This parameter will be updated every 10s using a timer. Now I would like to use the changing value of this parameter to give the test person feedback. I was thinking of doing this by having a dark backround with a filled circle in the middel of the screen. This circle should change color according to the performance of the subject.
So far I had the following idea:
x = [0 0 1 1 0];
y = [0 1 1 0 0];
h = fill(x,y,[0.2, 0.2, 0.2])
hold on
rectangle('Position', [0.4 0.4 0.2 0.2], 'Curvature', [1 1], 'FaceColor', [x 1-x 0]) % with x = parameter
axis off
Problems with this is that I would realy like for the full screen would be used. So I don't want to see the matlab figure in the figure window anymore. How could I do this?
Another problem is that my circle no longer looks like a circle when I maximize the window. (Because my computer screen isn't square.) Does anybody have an idea on how I could solve this?
Other suggestions for better plots of visualisations would be very much appreciated!
The goal is that the participant gets a color coded feedback on how well he is doing e.g. green = good, red = bad, orange = something in between,...

回答(1 个)

Baltam
Baltam 2016-4-14
编辑:Baltam 2016-4-14
Hi fellow Belgian,
Look at the following code and the provided comments
x = [0 0 1 1 0];
y = [0 1 1 0 0];
% 'name' and 'numbertitle' to remove 'figure 1' and replace it with
% 'Performance'. 'outerposition' and 'unit' to go "full screen". 'color' to
% make white background'. 'menubar' to hide the menubar.
hfig = figure('name','Performance','numbertitle','off','unit','normalized','outerposition',[0 0 1 1],'Color',[1 1 1],'menubar','none');
% loop over x for example
for i =1:numel(x)
rectangle('Position', [0.0 0.0 1 1], 'Curvature', [1 1], 'FaceColor', [x(i) 1-x(i) 0]) % with x = parameter
ax = gca;
% remove tick labels
set(ax,'XTick',[]),set(ax,'YTick',[])
% make lines of the axes white --> invisible on white background
set(ax,'XColor',[1,1,1]) , set(ax,'YColor',[1,1,1])
% make axes square to get round circle
axis square
pause(0.5)
end
Kind regards, Baltam

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by