String and Vectors in one matrix 2x5

1 Ansicht (letzte 30 Tage)
Paula
Paula am 3 Okt. 2013
Beantwortet: Paula am 4 Okt. 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Paula
Paula am 4 Okt. 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)]

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by