Path: news.mathworks.com!not-for-mail
From: "steven berruyer" <steven.berruyer@voila.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Atomic Weight
Date: Tue, 6 Oct 2009 23:39:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <hagkeo$pda$1@fred.mathworks.com>
Reply-To: "steven berruyer" <steven.berruyer@voila.fr>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1254872344 26026 172.30.248.37 (6 Oct 2009 23:39:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 6 Oct 2009 23:39:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2025731
Xref: news.mathworks.com comp.soft-sys.matlab:575475


Hello,

I try to right a program to calcul the atomic weight of molecules.
I have the periodic table in cells.

My prog is:

load tableperiodique

FormChim=input('Entrez dans un ensemble de cellule le symbole chimique des atomes composant la mol?cule s?par?s par des espaces: \n','s');
NbOcc=input('Entrez une matrice de m?me dimensions que la pr?c?dente contenant le nombre d''occurrence de chacun des atomes dans la formule chimique: \n')


 
 MasseAt=0;
 for el=1:length(NbOcc)
     
     for i=1:109
     
          if isequal(table_periodique{i,2},FormChim{el})
             MasseAt=MasseAt+table_periodique{i,1}*NbOcc(el);      
          end
          
     end
 end

MasseAt

It's function but it's not "user friendly", because for the name of molecule, user has to write: {'O' 'H'} for example
and for the number of atom : [1 2]
I want to try to ameliorate that. I want the user have to write: H 2 O 1
but I don't know how to indicate to Matlab that H and O are letters. And how to delete the blank beetween the characters....

Is there a special function? Maybe I have to use cells...I don't know.
Does anyone can help me?

Thanks a lot

Steven