I am looking for a way to take the values from a matrix and sorting them into different empty arrays.

1 vue (au cours des 30 derniers jours)
Im looking for a way to take the values from matrix(given under) and sorting them into diffrent empty arrays (A and B).
A = char.empty;
B = char.empty;
vector1 = [1,0,0,0,0,1]';
vector2 = ([1,2,4,6,6,1])';
matrix = [vector2, vector1]
matrix =
1 1
2 0
4 0
6 0
6 0
1 1
My goal is to have the script recognize what values have a 1 behind it and what values have a 0 behind it so that A and B ends up looking something like this:
A = [1,1] %A being the array with values from matrix(:,1) that has a 1 in matrix(:,2)
B = [2,4,6,6] %B being the array with values from matrix(:,1) that has a 0 in matrix(:,2)
The ulttimate goal for the script segment is to have it funcion for any vector2, by manipulating vector1 from a zeroes vector using a menu system of sorts
%zero being the zeroes vector
zero = zeros(6:1)
%and want this to be manipulated using a menu or something to become a vector composed of
%ones and zeroes according to a selection in the menu
%so that it ends up looking like vector1 from the code above
Sorry if its badly formulated but my english is'nt the best in the world and my understanding of Matlab is a little subpar, so if you have questions about what im trying to achieve then feel free to ask. And thank you in advance for any help.

Réponse acceptée

David Hill
David Hill le 23 Sep 2020
A=vector2(vector1==1);
B=vector2(vector1==0);
  6 commentaires
David Hill
David Hill le 23 Sep 2020
Look at uipanel() and uicheckbox() and follow the examples.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by