MATLAB Answers

Colour plot vs Time on a circle

3 views (last 30 days)
Sankar Ram T
Sankar Ram T on 25 May 2020
Edited: Sankar Ram T on 30 May 2020
I have temp vs time data for 100 points along a circle.
I would like create a small animation of the temp vs time basedon colour of the circle.
(If not a circle I would atleast like to try it along a line. )
Is it possible somehow?
A sample/Example would be like this
This has 6 frames, with the color representing the temperature and frames representing the passage of time.
Here it is made as a contiuous diagram, with smooth gradients. If it is not possible, is it possible as discreet sections of a circle.
  4 Comments
Sankar Ram T
Sankar Ram T on 26 May 2020
Coloum 1 is Time (Sec)
Rest are temperatures of 20 Sectors

Sign in to comment.

Answers (1)

Kelly Kearney
Kelly Kearney on 26 May 2020
It's not clear to me whether you've already created the circle plots in Matlab, or if you just sketched out your desire outcome.
If you haven't plotted them yet, I think using a simple patch is the easiest way to achieve that look. To animate, it depends on whether you just want to animate on screen or export to something like a gif. The example below shows the former.
% Some example data
t = linspace(0,1,100)'; % time coordinate, normalized
data = rand(100,3); % three time steps of random data
% Use patch to plot the circle
th = 2*pi*t;
rmin = 0.8; % inner radius
rmax = 1; % outer radius
xouter = rmax.*cos(th);
xinner = rmin.*cos(th);
youter = rmax.*sin(th);
yinner = rmin.*sin(th);
x = [xouter; xinner(end:-1:1); xouter(1)];
y = [youter; yinner(end:-1:1); youter(1)];
c = [data; data(end:-1:1,:); data(1,:)];
axes
p = patch(x,y,c(:,1));
axis equal;
set(gca, 'visible', 'off');
set(p, 'edgecolor', 'none');
% Loop over to animate
for it = 2:size(data,2)
pause(1);
set(p, 'cdata', c(:,it));
end
  3 Comments
Sankar Ram T
Sankar Ram T on 29 May 2020
By the time I undersood your pevious code, you made a improved version. 👍👍
I had worked around the previos code to plot my data. I found 2 bugs.
1) The top of the image has a 'patch'. The colours are not uniform there. What would cause that?
(May be the vertices on outer and inner are not lining up corretly???)
2)There is a jump in colour towards the right side of circle. I believe it is the start of the patch. Any way to smoothen this out?
I will go through the 2nd set of code, and get back. THANK YOU for the prompt reply.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!