using xls read to read value from column /row in a for loop

4 ビュー (過去 30 日間)
Maria Imdad
Maria Imdad 2020 年 12 月 19 日
編集済み: KALYAN ACHARJYA 2020 年 12 月 19 日
Hi everyone, i have a file of binary data(i.e. 0 and 1) only as , 128rows and 128 columns. all i want is my for loop to take one row or column at time and assign its value to key_out variable, and in next iteration it moves to 2nd row or column. Right now i have this code given below, but its not working fine, i will be very glad if someone can help me.
filename = 'binary.xlsx';
sheet=1;
key_out=xlsread(filename,sheet);
key_out=sprintf('%g', key_out);
disp(key_out);
key_out= reshape(key_out, [],128);
disp(key_out);
for j=1:128
my_out= masterkey (key_out);
%two more functions will be executed here, for each 128 bits of j
end

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 12 月 19 日
You need to specify row and column indices. Try this
for j=1:128
my_out= key_out(:,j); % extracts the jth column
end

その他の回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 12 月 19 日
編集済み: KALYAN ACHARJYA 2020 年 12 月 19 日
You can do the same without Loop also (Using Cell Array)
  • Saving all Rows as key blocks
key_blocks=mat2cell(binary_data,1*ones(1,128),128);
  • Or Saving all Cloumns data as key blocks
key_blocks=mat2cell(binary_data,128,1*ones(1,128));
Later you call any data from cell array using key_blocks{row/column number}

カテゴリ

Help Center および File ExchangeSchedule Model Components についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by