re-running a for loop for 100s of different ranges
Afficher commentaires plus anciens
Hi experts hope you can help me :)
I would like to re-run a 'for' loop for 100s of different ranges. the loop is below in the code. I believe it will need a loop in a loop but I don't know how to do this, I have a list of the ranges (x and y values that make the range), but how do I implement this so that it does the loop for k=58:69 then again for K=78;89 then for k=90:102 ect, (no pattern in rages). Hope this is clear what am trying to do. any input would be much appreciated.
%Clearing and formatting
clear all;
close all;
format long;
%getting range of each scan
Scan_ranges = xlsread('aCopy of spray 144_plume scans','B:C');
%creating results file
z=[];
% control loop to process all files in the range k
for k = x:y
%Importing data
open_file = csvread((sprintf('C1charlie %d.csv', k)),5,0);
%Seperating data
Time = open_file(:, 1);
Ampl=open_file(:,2);
%Seperating positive and negative data for time and amplitude
ind_pos = find(Time>0);
ind_neg = find(Time<0);
Ampl_pos= Ampl(ind_pos);
Ampl_neg= Ampl(ind_neg);
%Finding the standared deviation of the amplitudes and muiliplying by 1e4
SD_I_pos = std(Ampl_pos)*1e4;
SD_I_neg = std(Ampl_neg)*1e4;
%Choosing the smaller of the two amplitudes
if SD_I_pos>SD_I_neg
z = [z mean(Ampl_neg)*1e4];
else
z = [z mean(Ampl_pos)*1e4];
end
end
Réponse acceptée
Plus de réponses (1)
Alexander
le 13 Juil 2013
0 votes
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!