String and Vectors in one matrix 2x5

1 回表示 (過去 30 日間)
Paula
Paula 2013 年 10 月 3 日
回答済み: Paula 2013 年 10 月 4 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 3 日
編集済み: Azzi Abdelmalek 2013 年 10 月 3 日
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 件のコメント
Paula
Paula 2013 年 10 月 4 日
Thank you it works if my outputdata 5x1 but it won't work if my outputdata vector is 5x4 :(
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 10 月 4 日
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)]

サインインしてコメントする。

その他の回答 (1 件)

Paula
Paula 2013 年 10 月 4 日
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)]

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by