Combining matrices
Mostrar comentarios más antiguos
I'm trying to build a matrix with the number of occurences of a given condition from two matrices.
The objective is to now the number of points that correspond to a given statement and combining this into a m*n matrix to use on a plot
For example: how many waves have period<0.5 and height<1, how many waves have period<0.5 and 1<height<1.5. etc...
my class intervals are period=[0:1:17] and height=[0:0.5:10].
Is there a way to build a function that would in some way combine the two classes into a matrix that would help me build something like (I'm only interested in the numbers):
t=[period H] x=matrix size(t) %with the number of occurences of each class.
I tried using multiple for and if conditions and even simpler ways, but I'm feeling really lost.
Can someone help me?
thank you in advance
Paul
Respuesta aceptada
Más respuestas (2)
John Petersen
el 9 de Nov. de 2011
0 votos
Paul, Try find() or a straight comparison (if you don't need to know the indices). For example,
function [num_periods, num_heights] = findnum(period,plowvalue,phighvalue,height,hlowvalue,hhighvalue)
num_periods = sum((period>plowvalue)&(period<phighvalue));
num_heights = sum((height>hlowvalue)&(height<hhighvalue));
1 comentario
Paul
el 9 de Nov. de 2011
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!