How to save in n different variables a vector data separated by comma
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi everybody.
I need help please. Anyone know how can I save a vector number composed by 2 columns and n rows in 2 different variables?. For example in the first iteration, the vector is like the following:
RX=[1.23,4.56]
I expect the algorithm divide the vector until the comma then create the variables A and B with the coefficients data:
A=1.23
B=4.56
Thanks
댓글 수: 0
답변 (1개)
Star Strider
2019년 4월 9일
It will do that for cell arrays, although not numerical arrays:
RX=[1.23,4.56];
RXc = num2cell(RX);
[A,B] = RXc{:}
producing:
A =
1.23
B =
4.56
Note that this is relatively new, however I don’t remember the MATLAB version that introduced this. If you cannot reproduce the result I posted here with your version, you may need to use the deal (link) function.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!