Cell arrays and structure
The amino acids are important in protein building. These acids contain molecules of oxygen (O), carbon (C), nitrogen (N), sulfur (S), and hydrogen (H).
In exercises 1-4 you will use cell arrays and structure arrays to store data about atom weights and the formula of amino acids. The overall task will be to create the array data in matlab and write a function that uses this data to calculate the molecular weight of any amino acid. The easiest way to approach this is to break up the task into smaller tasks and write a function for each.
The first function you need to write will create a cell array and structure array and populate them with data about the element weights and amino acid formulae. Use the function header:
function [w s] = generate_array()
This function has no inputs. There are two outputs; w is the cell array of element weights and s is the structure array of amino acids.
The following table lists the relevant elements and their molecular weights in Daltons:
Element |
Weight |
Oxygen |
15.9994 |
Carbon |
12.011 |
Nitrogen |
14.00674 |
Sulfur |
32.066 |
Hydrogen |
1.00794 |
In your function, create a cell array w that stores the molecular weight of each atom, with atom names in the first column and corresponding weights in the second.
The table below shows the chemical formula of 4 amino acids:
Amino acid |
Chemical formula |
Isoleucine |
C6H13NO2 |
Lysine |
C6H14N2O2 |
Methionine |
C5H11NO2S |
Phenylalanine |
C9H11NO2 |
In your function, create a structure array s, that stores the formulation of each Amino Acid. Each element of the array should be a structure with 6 variables, one for the amino acid’s name and one that stores the number of each atom that exist in the amino acid’s formula.
Test your function. Try the follow example commands and see if you get the same results (your variable names may be different):
>> [w s] = generate_array(); >> s(1).name Isoleucine >> s(1).c 6 >> s(1).s 0 >> w{3,1} Nitrogen
Copy and paste your function code into the textbox