How do I read in a text file (CREATED FROM BINARY IMAGE OF ROWS-420 AND COLUMNS 680) and sort it by a ROW

1 回表示 (過去 30 日間)
I created a file from binary image which consists of 420 rows and 680 columns, in which I am trying to read and then sort by row 1 and then by row 2,etc.....
i have to calculate number of 1 in each row..
can anyone please suggest the ,matlab code.
Thanks in advance.

採用された回答

Bhaskar R
Bhaskar R 2020 年 2 月 24 日
x = logical(randi([0,1], 420, 680 )); % assumed that x is your extracted data from the text file
x_sorted = sort(x, 2); % sorted array
x_1_count = sum(x, 2); % counted number of 1's in each row
  2 件のコメント
Bhaskar R
Bhaskar R 2020 年 2 月 24 日
編集済み: Bhaskar R 2020 年 2 月 24 日
you can read data from text file as
f= fopen('your_text_file.txt', 'r');
x = textscan(f, repmat('%d', 1, 680), 'CollectOutput', 1, 'Delimiter', ',');
x = x{1};
fclose(f);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by