Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with matlab char arrays

Status
Not open for further replies.

SnkMajin

Bioengineer
Joined
Nov 1, 2004
Messages
2
Location
GB
Hi

I'm new to matlab, and i'm having some trouble and hope that you can help.

I need to create a 100 row * 500 col array in which each element holds one of 4 letters (a,t,g,c - dna). I'n not sure how to do this, yet.

Will i need to create a for loop? and how can i fill an array in matlab with letters?

I'd really apprciate any help

Thanks for your time

SnkMajin
 
You don't need to but you can create a for loop. It won't affect your execution time.

Here is one solution to your problem
Code:
dna = ['a' 't' 'g' 'c'];
r = ceil(4*rand(100,500));  % generates random numbers 1-4 in a 100x500 matrix
m = dna(r);                 % matrix of random dna.
 
Hi JockeK,

Wow thanks, that works a treat! :D
I've been wracking my brain and had no joy! Had a different approach but your is way better.
I'm gonna have to manipulate this array now and think i have an idea.

Hope you dont mind me pestering you if icant get it to work.

Thanks again!
SnkMajin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top