Using a matrix to define which rows to display from another
1 view (last 30 days)
Show older comments
I have a matrix that describes the rows i want to pull out and display from a matrix. I need to get the middle three rows out of the matrix. I took the median of the first column and then made a column with the values of the rows I need. Can I use the matrix to define the rows? M_med = median(Estress); medloc = find(Estress(:,1)==M_med); medloc1 = medloc + 1; medloc2 = medloc - 1; med=[medloc2, medloc, medloc1] M =
1.0e+08 *
0.000012802859624 0.000010004800000 0.512872314238545 0.000000069092342
0.000025604759872 0.000010019200000 1.027181030849996 0.000000069106710
0.000038834541379 0.000010035200000 1.560402940258872 0.000000069122651
0.000041821075812 0.000010040000000 1.681207247660731 0.000000069127428
0.000042674919579 0.000010042800000 1.716009726176837 0.000000069130214
0.000043101841462 0.000010047600000 1.734004322766417 0.000000069134988
0.000043528763346 0.000010055600000 1.752572481327140 0.000000069142939
0.000043529722721 0.000010056000000 1.752680755624243 0.000000069143336
0.000044396038362 0.000010073200000 1.790616536066220 0.000000069160409
0.000045961738393 0.000010153600000 1.868546897320170 0.000000069239829
0.000047042954039 0.000010248400000 1.930341758850655 0.000000069332671
0.000047836357179 0.000010350400000 1.982415179682283 0.000000069431610
0.000048222985312 0.000010423600000 2.012557358197854 0.000000069502016
0.000051051222867 0.000010949200000 2.237922246566006 0.000000069993495
0.000053879460422 0.000011650000000 2.512938034068724 0.000000070613344
%med=[ 7 8 9 ]
3 Comments
Answers (1)
Rik
on 15 Sep 2018
med=(-0.5:1.5)+size(M,1)/2;
1 Comment
Rik
on 19 Sep 2018
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!