How can I link elements in corresponding rows of two matrices of the same dimension?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jasmine
el 9 de En. de 2019
Comentada: Star Strider
el 9 de En. de 2019
Hey everyone! I need a bit of help with something. I'm more like a beginner in learning Matlab and I have some trouble with creating a program.
I have 2 matrices of the same dimension:
A = blk.visDiff(:,1);
B = blk.responseMade(:,1);
And I want to count for each element of A the number of times the corresponding element in B is 1 (when I say corresponding element I mean that if I would have merged the two matrices in one matrix with 2 columns, the 2 "corresponding" elements will be in the same row of the final matrix), and then divide the number calculated by the total times of A being equal to each specific value.
For example:
calculate how many times A = 100 and B = 1 --> and then divide this number by the number of times A = 100
I always need to calculate this for B=1, but there are multiple values of A (11 values to be more exact). I want plot in the end the each values of A (e.g. 1, 80, 60..., -60, -80, -100) against the fraction of number of times when B was 1.
How can I write this in a program?
(The two matrices can also be merged in the program, this aspect is not important)
Respuesta aceptada
Star Strider
el 9 de En. de 2019
See if the findgroups (link) and splitapply (link) functions will do what you want. (They were introduced in R2015b.)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB 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!