Clear Filters
Clear Filters

How to save in n different variables a vector data separated by comma

1 view (last 30 days)
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

Answers (1)

Star Strider
Star Strider on 9 Apr 2019
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.

Community Treasure Hunt

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

Start Hunting!