フィルターのクリア

Replacing row specific value rows of table with corresponding table values

2 ビュー (過去 30 日間)
Matt Brianik
Matt Brianik 2018 年 1 月 16 日
コメント済み: Matt Brianik 2018 年 1 月 16 日
I need to replace all the values of 999999 in a row of a table with the value 0.0001, then i need to go to the next row and replace the same values of 999999 with 0.0002, i need to do this for variable numbers of rows depending on the data being read in.
the code i have working so far is as follows:
i=i+1;
for
x=1:Number_of_Compounds;
Number_of_Compounds(i,:)=(Number_of_Compounds==999999)=MDL_Codes(i)
i=i+1
end
In Short i need to be able to replace identifier numbers in a table with another value unique to that row.
I also tried using the find command but was unable to figure out how to indicie it so that it only made changes to one row and not the entire spreadsheet.
for x=1:Number_of_Compounds;
TableCompounds(i)=Table_Compounds(find(Table_Compounds==999999))=MDL_Codes(i)
i=i+1;

回答 (1 件)

KSSV
KSSV 2018 年 1 月 16 日
N = 10 ;
A = rand(N) ;
% put NaN's randomly
A(randperm(N*N,round(40*N*N/100))) = NaN ;
B = A ;
% replace NaN's
for i = 1:N
num = i/1000 ; % replace with this
A(isnan(A(i,:)),:) = num ;
end
  1 件のコメント
Matt Brianik
Matt Brianik 2018 年 1 月 16 日
The isn't working in the way that I need it to. issue is that I need to replace different values within each row, NAN values in row 1 need to be x, NAN values in row 2 need to be y, etc... this doesn't do that

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by