How to pull similar data from different sized matrices?
Mostrar comentarios más antiguos
I have matrices that are a lot of rows and 2 columns. The first column is a linspace from 1 to a lot and the second column is data for a specific parameter. These matrices change in row size for each new file I load. I am plotting each parameter and plot brushing and saving(ans) a specific time frame I will use for further analysis. I would like to apply this time frame to each parameter.
Previously I would find the max and min values of my linspace that I brushed and assign that range to each parameter.
brushed_data = ans(:,1)
size2 = size(brushed_data,1)
Start = min(brushed_data)
Stop = Start+size2-1
My new parameters would then be assigned like so:
IAMHS2 = IAMHS(Start:Stop,1);
My new parameters aren't all the same size though. When I read the file in I have to remove rows for some parameters because they are empty (NaN). For example two parameters will look something like
set1 = [1 data; 2 data; 3 data; 4 data; 5 data; 6 data; 7 data; 8 data; 9 data; 10 data]
set2 = [2 data; 4 data; 6 data; 9 data; 10 data]
I would like to be able to recognize the min and max linspace values of the brushed data.
brushed_data = ans
start = min(brushed_data(:,1))
stop = max(brushed_data(:,1))
Then pull all values greater then or equal to the start values and less than or equal to the stop values. (This is my problem)
>=Start and <=Stop
So for instance if I brushed data in set1 for values 3-9 I would like to be able to reassign set2 for the same range. So it would only contain
[4 data; 6 data: 9 data]
Similarly if I brushed data in set2 for values 4-9 I would reassign set1 for the same range.
[4 data; 5 data; 6 data; 7 data; 8 data; 9 data]
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Workspace Variables and MAT Files 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!