I have a matrix [301,4201] and I would like to select only the values ​​ >=1.5.

1 回表示 (過去 30 日間)
Alice Zaghini
Alice Zaghini 2021 年 6 月 24 日
コメント済み: Steven Lord 2021 年 6 月 25 日
However I don't know the position of the values inside the matrix. In the end I would always get a matrix (I don't know the final dimension).
  5 件のコメント
Alice Zaghini
Alice Zaghini 2021 年 6 月 24 日
I have an already constructed matrix of dimensions 301x4201, I would like to obtain a submatrix with only values ​​greater than 1.5. I have already tried with the command ''find'' but it returns me a vector but I want a submatrix.
Steven Lord
Steven Lord 2021 年 6 月 25 日
What if only 17 of the values in your matrix were greater than 1.5? What exactly would you want the shape of that submatrix to be? You have two choices in that case (assuming you don't want to add dimensions): it must be of size [1 17] or [17 1].
What if only 1000 of the values in your matrix were greater than 1.5? What shape would you want the submatrix to have?
Please explain in detail exactly what you want the submatrix to look like in those cases. That information may help us determine if what you want is possible in MATLAB and how to achieve it if it is.

サインインしてコメントする。

回答 (1 件)

Sean Brennan
Sean Brennan 2021 年 6 月 24 日
This might help. The example below uses a random 10x10 matrix as a placeholder to demo the "find" command.
dummy_data = rand(10,10)*2; % Create a random 10x10 matrix where data is scattered between 0 and 2
% Find indices where data is larger than 1.5. These will range from 1 to
% 100 since there are 10x10 different elements, and MATLAB numbers them 1
% to 100 with 1,2,3 going down the first column, 11,12,13 down second
% column, etc. See ind2sub() to convert from MATLAB's internal indices to
% row,col form.
indices_big_number = find(dummy_data>1.5)
dummy_data(indices_big_number) % Show the results
% If you need the row and column, and don't like ind2sub, then use this
% [row_index,col_index] = find(dummy_data>1.5); % Find indices where data is larger than 1.5
  2 件のコメント
Alice Zaghini
Alice Zaghini 2021 年 6 月 24 日
Thank you for your answer. I tried your method but I haven't solved my problem.
Sean Brennan
Sean Brennan 2021 年 6 月 24 日
Sorry to hear. Can you be more specific, so we can help you more specifically?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by