Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Movies about particles with changing colours

10 views
Skip to first unread message

Harshit

unread,
Feb 20, 2012, 4:03:11 PM2/20/12
to
For my assignment I am supposed to read particle positions from a file (2 particles) which are moving towards each other over time, then colliding and moving back.

The question requires the particles to be given dimensions that is a shape and they should be colored the hint says we can use "fill" or a "patch" command to give the particles size and colour and the catch is that the colour of the particles should change with the change in velocity which is also a file.

Does anyone have any idea how to do any of that!

ImageAnalyst

unread,
Feb 20, 2012, 4:32:28 PM2/20/12
to
------------------------------------------------------------------------------
Read the file, say using dlmread(), csvread(), load(), fgetl(),
textscan() or something similar.
The x,y,y coordinates should then be in an array. Assuming each
element or row is one specific time, then you can use diff() to find
the velocity, which is just the difference in the distances divided by
the time difference (which is 1 unit). So for each time, you now know
the location and the velocity. From the velocity you can assign a
color, for example

colorTable = jet(100);
thisColor = jet(round(velocity));
assuming velocities are in the range 0-100. Scale things if they are
not in that range.
Then call fill or patch to draw a polygon at the specified location
with thisColor.

I think these are major hints and guidance and you should be able to
take it from here. Almost anything additional and I'd just be handing
the code over to you.

harshit gupta

unread,
Feb 20, 2012, 4:42:53 PM2/20/12
to
Thanks a lot i think i can workout from your points, thanks again for
the quick response.

Harshit

unread,
Feb 21, 2012, 4:53:10 AM2/21/12
to
I Tried your solution actually velocity is read from a file as well, the position and velocity of the particles are calculated using Euler algorithm, I dont have any problem reading from the file and writing to the file the only problem I have is changing those colours based on the continuous changing velocity and your soulution is not working. The color remains the same even though i checked the value of the velocity is changing contunuously, btw, I am using it with 'set' right now and not 'fill' or 'patch' but i still think it should work.

Steven_Lord

unread,
Feb 21, 2012, 10:13:52 AM2/21/12
to


"Harshit " <h.g...@student.utwente.nl> wrote in message
news:jhvpi6$oq6$1...@newscl01ah.mathworks.com...
Depending on what type of visualization you're looking for, I think SCATTER
or SCATTER3 may be of interest to you.

--
Steve Lord
sl...@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

0 new messages