String and Vectors in one matrix 2x5

1 visualizzazione (ultimi 30 giorni)
Paula
Paula il 3 Ott 2013
Risposto: Paula il 4 Ott 2013
Hello I have the following situation:
I calculated some number using a number of variables
I would like my final outcome to show the name of the variable as a string and the numerical value corresponding to this string. I would like to store my final calculation as column vector. So far I created two different vector C & outputdata
C =
dil_PFV_CORRECTED_NaCl
dil_PFV_CORRECTED_HEPES
dil_PFV_CORRECTED_ZnCl2
dil_PFV_CORRECTED_DTT
dil_PFV_CORRECTED_MgSO4
outputdata =
1.0875e-01
1.0220e-02
3.1722e-06
1.0037e-02
5.1099e-03
I would like the final outcome to be just one matrix 2x5 :
[dil_PFV_CORRECTED_NaCl 1.0875e-01
dil_PFV_CORRECTED_HEPES 1.0220e-02
dil_PFV_CORRECTED_ZnCl2 3.1722e-06
dil_PFV_CORRECTED_DTT 1.0037e-02
dil_PFV_CORRECTED_MgSO4 5.1099e-03]
I will really appreciate any help P.V

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 3 Ott 2013
Modificato: Azzi Abdelmalek il 3 Ott 2013
C ={'dil_PFV_CORRECTED_NaCl'
'dil_PFV_CORRECTED_HEPES'
'dil_PFV_CORRECTED_ZnCl2'
'dil_PFV_CORRECTED_DTT'
'dil_PFV_CORRECTED_MgSO4'}
outputdata =[ 1.0875e-01
1.0220e-02
3.1722e-06
1.0037e-02
5.1099e-03]
result=[C num2cell(outputdata)]
  2 Commenti
Paula
Paula il 4 Ott 2013
Thank you it works if my outputdata 5x1 but it won't work if my outputdata vector is 5x4 :(
Azzi Abdelmalek
Azzi Abdelmalek il 4 Ott 2013
why it doesn't work?
C ={'dil_PFV_CORRECTED_NaCl'
'dil_PFV_CORRECTED_HEPES'
'dil_PFV_CORRECTED_ZnCl2'
'dil_PFV_CORRECTED_DTT'
'dil_PFV_CORRECTED_MgSO4'}
outputdata =randi(10,5,4)
out=[C num2cell(outputdata)]

Accedi per commentare.

Più risposte (1)

Paula
Paula il 4 Ott 2013
I am not sure. This is what I have :
C ={'dil_PFV_CORRECTED_NaCl' 'dil_PFV_CORRECTED_HEPES' 'dil_PFV_CORRECTED_ZnCl2' 'dil_PFV_CORRECTED_DTT' 'dil_PFV_CORRECTED_MgSO4'}
outputdata= [dil_PFV_CORRECTED_NaCl;dil_PFV_CORRECTED_HEPES;dil_PFV_CORRECTED_ZnCl2;dil_PFV_CORRECTED_DTT;dil_PFV_CORRECTED_MgSO4]'
result=[C num2cell(outputdata)]

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by