loop for different columns
Show older comments
Hi every one
i want to write a loop but i get confused
i have a data with 103 rows and 811 columns. i want calculate 6 parameters for all the columns. at last i should have a matrix with 811 rows and 6 parameters. please help me. i know that i cant find the right position of the counter n trough the loop.
Y1='Y1.xlsx'
Y1=xlsread(Y1);
z2_real=Y1(:,1);
threshold = 4;
N=size(Y1,2);
n=1
for i=1:N
Y1_new(:,n)=Y1;
[r_z2_real,c_z2_real]=size(z2_real);
[rows_rl, columns_rl] = find(z2_real > threshold);%number of real active cmpds [rows_tn, columns_tn] = find(Y1 > threshold);%number of predicted as active cmpds [rows_rl_tp, columns_rl_tp] = find(z2_real < threshold);%number of real inactive cmpds [rows_tp, columns_tp] = find(Y1 < threshold);%number of predicted as inactive cmpds NTN = nnz(ismember(rows_tn,rows_rl));%NTN:number of correct active cmpd NTP = nnz(ismember(rows_tp,rows_rl_tp));%NTP:number of correct inactive cmpd FC=((NTN+NTP)/r_z2_real)*280; [rr_rows_rl_tp,cc_rows_rl_tp]=size(rows_rl_tp); [rr_rows_tp,cc_rows_tp]=size(rows_tp); NFP=abs(rr_rows_tp-NTP);%NFP:number of cmpds that model determined as actice cmpd incorrectly FAR=((NFP/(NTN+NTP))*280); [rr_rows_rl,cc_rows_rl]=size(rows_rl); [rr_rows_tn,cc_rows_tn]=size(rows_tn); NFN=abs(rr_rows_rl-NTN);%NFP:number of cmpds that model determined as inactice cmpd incorrectly POD=(NTP/(NFN+NTP))*280;
[rows_tn, columns_tn] = find(Y1_new > threshold);%number of predicted as active cmpds
[rows_rl_tp, columns_rl_tp] = find(z2_real < threshold);%number of real inactive cmpds
[rows_tp, columns_tp] = find(Y1_new < threshold);%number of predicted as inactive cmpds
NTN = nnz(ismember(rows_tn,rows_rl));%NTN:number of correct active cmpd
NTP = nnz(ismember(rows_tp,rows_rl_tp));%NTP:number of correct inactive cmpd
FC=((NTN+NTP)/r_z2_real)*100;
[rr_rows_rl_tp,cc_rows_rl_tp]=size(rows_rl_tp);
[rr_rows_tp,cc_rows_tp]=size(rows_tp);
NFP=abs(rr_rows_rl_tp-rr_rows_tp);%NFP:number of cmpds that model determined as actice cmpd incorrectly
FAR=((NFP/(NTN+NTP))*100);
[rr_rows_rl,cc_rows_rl]=size(rows_rl);
[rr_rows_tn,cc_rows_tn]=size(rows_tn);
NFN=abs(rr_rows_rl-NTN);%NFP:number of cmpds that model determined as inactice cmpd incorrectly
POD=(NTP/(NFN+NTP))*100;
ss(n,:)=[NTN,NTP,NFP,NFN,FC,FAR,POD];
ss(isnan(ss))=0;
% i=i+1
xlswrite('classification_results.xlsx',ss,'results');
end
%
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!