How to conditionality concat columns of a matrix?
Mostra commenti meno recenti
Hi everyone,
My data set consists of 60 rows and 86 columns. First row is parameter values that are ranging from 1.2 to 1.73. I required to select columns based on the parameter values. In the below example, I select all the columns having parameter value between 1.2 and 1.3. However, it is a bit hard to compute this manully. May someone help me tyo automate this for a window of 0.5.
For exmaple, same process repeat for 1-1.5, 1.5-2, 2-2.5 and so on. and store mean parametere values in one matrix and selected columns in another matrix.
format short
% Lines below this are not important .........
X = load('PDS_case.csv'); % input data
C_sort = sortrows(X,5);
Tri = C_sort(1:86,:);
data1 = sortrows(Tri,7);
PDS=(data1(:,7));
dd=(PDS*1e8);
data2=data1(:,8:66);
Arr=[dd data2]
A=Arr';
% Lines below this are important ...........
TheArray=A; % Data set after preliminary processing
C=1.0; % lower limit for parameter value
D=1.5; % upper limit of the parametere values
mask = (TheArray(1,:) < D & TheArray(1,:)>C); % Masking condition
output = TheArray(:,mask); % selected array
pds=mean (output(1,:)); % mean of the parameteres velues of the selected coloumns
ev=output(2:end,:); % Delete parametere row from selected data
d1 = ev(:); % matrix converted to column matrix
1 Commento
Stephen23
il 5 Apr 2022
"same process repeat for 1-1.5, 1.5-2, 2-2.5 and so on"
Then you need to ignore any badly-written code written using loops to repeat code. That will not make your task easier.
A much better approach would use discretization functions to bin the data, e.g. HISTCOUNTS:
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!