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 CenterFile Exchange에서 Introduction 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