Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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

Respuestas (1)

Star Strider
Star Strider el 9 de Abr. de 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.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by