MATLAB Answers

how can I combine two columns of an array A(m*2) in one column in the format: column1(column2)?

조회 수: 2(최근 30일)
Joseph 20 Oct 2015
Commented: Joseph 20 Oct 2015
i have a cell array A(m*2). the first column of consist of R and P characters and second column is just numbers. now i want put 2 columns together in the format P(number) or R(number) in which the numbers inside parenthesis are the elements of second column. can any one help with this?
thank you;

  댓글 수: 2

Image Analyst
Image Analyst 20 Oct 2015
I don't understand. You can't have characters and numbers in the same column vector. Please give an example.
Joseph 20 Oct 2015
example: linlist=horzcat(Branch,num2cell(JJ));
JJ is a matrix that includes numbers and Branch is a cell that includes characters(in this case, R and P). i put them together using horzscat and made linlist cell.

로그인 to comment.

채택된 답변

Mohammad Abouali
Mohammad Abouali 20 Oct 2015
So, if I understood you right you have A of size Mx2 where the first column has either the character R or P and the second column has a number. You want to have two other variables One named R and another Named P which they contain the corresponding numbers from the second column of A?
If that's what you want here is a sample code:
A={'R',1; ...
'P',5; ...
'R',3; ...
'R',10; ...
'P',6; ...
R =
P =

  댓글 수: 2

Joseph 20 Oct 2015
i just want to make a string with the format P(number) or R(number)., in which the numbers belong to second column. i know that i can use strcat but i don't know how to put the numbers in second column in the parenthesis.
Joseph 20 Oct 2015
figured it out, thank you tho for your answer. i meant below:

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by