loop for different columns
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mary moz
el 14 de Nov. de 2020
Comentada: mary moz
el 15 de Nov. de 2020
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
%
0 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Nov. de 2020
xlswrite('classification_results.xlsx',ss,'results');
You are always writing the ss vector of results to the same location in the file.
Change
% i=i+1
xlswrite('classification_results.xlsx',ss,'results');
end
to
all_ss(i, :) = ss;
end
xlswrite('classification_results.xlsx', all_ss, 'results');
2 comentarios
Stephen23
el 15 de Nov. de 2020
mary moz's incorrectly posted and accepted "Answer" moved here:
Thanks for the reply. but the problem is still exist. i get the following error.
Subscripted assignment dimension mismatch.
Error in parameters (line 9)
Y1_new(i, :) = Y1
Más respuestas (0)
Ver también
Categorías
Más información sobre Holidays / Seasons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!