find a value & store in new variable (again)
Dear Matlab friends,
We recently posted a question about finding values and storing them in new variables:
http://www.mathworks.com/matlabcentral/answers/31471-find-a-value-store-in-new-variable
Our question remains in the sense that we would like to know how to procede when we have a matrix rathen than a cell array.
Indeed, we have a 384 x 14 matrix A, and we would like to find all occurrences of number [2] in column 1, and save corresponded value in column 2 in a new variable "new_variable":
A =
3 5 6 …
2 3 5
2 3 4
1 4 5
5 7 9
…
so the result would be:
new_variable =
2
2
The suggestion for cell arrays was
new_variable = A{2}(A{1} == 2);
We thank you very much for any suggestion!
Best,
UdiubuDear Matlab friends,
We recently posted a question about finding values and storing them in new variables:
http://www.mathworks.com/matlabcentral/answers/31471-find-a-value-store-in-new-variable
Our question remains in the sense that we would like to know how to procede when we have a matrix rathen than a cell array.
Indeed, we have a 384 x 14 matrix A, and we would like to find all occurrences of number [2] in column 1, and save corresponded value in column 2 in a new variable "new_variable":
A =
3 5 6 …
2 3 5
2 3 4
1 4 5
5 7 9
…
so the result would be:
new_variable =
2
2
The suggestion for cell arrays was
new_variable = A{2}(A{1} == 2);
We thank you very much for any suggestion!
Best,
Udiubu Dear Matlab friends,
We recently posted a question about finding values and storing them in new variables:
http://www.mathworks.com/matlabcentral/answers/31471-find-a-value-store-in-new-variable
Our question remains in the sense that we would like to know how to procede when we have a matrix rathen than a cell array.
Indeed, we have a 384 x 14 matrix A, and we would like to find all occurrences of number [2] in column 1, and save corresponded value in column 2 in a new variable "new_variable":
A =
3 5 6 …
2 3 5
2 3 4
1 4 5
5 7 9
…
so the result would be:
new_variable =
2
2
The suggestion for cell arrays was
new_variable = A{2}(A{1} == 2);
We thank you very much for any suggestion!
Best,
Udiubu save, variable, find MATLAB Answers — New Questions