Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

matlab

Name: Anonymous 2010-11-03 19:53

Oi can someone help me with this plotting a double helix shit with matlab?'

It's primarily a tracing problem, just need to fix some errors, otherwise nearly all of the code is already there.

function plotDNA(name)

% Read the file and extract data about the rows and columns
[num txt raw] = xlsread(name);
[row col] = size(raw);

% Find the number of rows that have RNA strands (not headers)
rna_length = row;

% If each link occurs every pi/4 radians, find how many complete
% revolutions will be made in order to generate the polymer spirals
th = linspace(0,(2*pi*(rna_length/8))-(pi/4));

% Make sure that x and y are chosen so that they are centered around
% the origin (0,0) and the radius is 0.5
x = cos(th)/2;
y = sin(th)/2;

% Plot the 1st polymer "slinky"
plot3(x,y,th,'b');
hold on

% Plot the 2nd polymer "slinky", starting at the opposite x and y
% coordinate from which the 1st polymer began
plot3(-x,-y,th, 'b');

% Find the angle at which each rna pair should begin and place the
% corresponding starting positions in a vector
pairs = (pi/4)*(1:rna_length);

% Begin the first plot at pi/4. Add pi/4 to p after each repetition
p = pi/4;

% Since first row is the header, the base pairs begin on the 2nd row, 1st
% column of raw.
for i = 2:row

  % Make sure that the corresponding pairs are chosen so they stem from the
  % (0,0) with the appropriate rotation. c corresponds to the x-coordinate,
  % and d corresponds to the y-coordinate.
  c = 0.5*cos(pairs(i));
  d = 0.5*sin(pairs(i));
       
        % Plot DNA lines with the correct corresponding colors
        switch raw{i,1}
            case 'Adenine'
                plot3([c 0],[d 0],[p p],'g')
                plot3([0 c],[0 -d],[p p],'r')
            case 'Uracil'
                plot3([c 0],[d 0],[p p],'r')
                plot3([0 -c],[0 -d],[p p],'g')
            case 'Cytosine'
                plot3([c 0],[d 0],[p p],'y')
                plot3([0 -c],[0 -d],[p p],'m')
            case 'Guanine'
                plot3([c 0],[d 0],[p p],'m')
                plot3([0 -c],[0 -d],[p p],'y')
        end
p = pi/4 + p;
end

 % =====================================================================
 %Do not change the lines below! They are correct!
view(0,0)
axis([-2 2 -2 2 -1 rna_length])

Name: Anonymous 2010-11-03 19:56

http://i.imgur.com/ox2tF.png

That's what it should look like at the end

This is what it looks like now

http://i.imgur.com/QuOs2.jpg

Name: Anonymous 2010-11-03 20:09

meh w\e didn't expect much matlab is kinda a dead language here

Name: Anonymous 2010-11-04 4:59

>>2
It's compressed. It looks different because the JPEG overlords have smashed it in with a hammer.
Also it'd only been 16 minutes, do you have ADHD?

Name: Anonymous 2010-11-04 6:02

Thread started by a cretin who can't shift a graph on the y-axis. This makes me very sad :(

Name: Anonymous 2010-12-05 21:48

>>6
Thanks!

Name: Anonymous 2011-02-03 1:37

Name: Anonymous 2011-02-18 14:16

<-- check my doubles

Don't change these.
Name: Email:
Entire Thread Thread List