String and Vectors in one matrix 2x5

1 visualización (últimos 30 días)
Paula
Paula el 3 de Oct. de 2013
Respondida: Paula el 4 de Oct. de 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

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 3 de Oct. de 2013
Editada: Azzi Abdelmalek el 3 de Oct. de 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 comentarios
Paula
Paula el 4 de Oct. de 2013
Thank you it works if my outputdata 5x1 but it won't work if my outputdata vector is 5x4 :(
Azzi Abdelmalek
Azzi Abdelmalek el 4 de Oct. de 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)]

Iniciar sesión para comentar.

Más respuestas (1)

Paula
Paula el 4 de Oct. de 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)]

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by