assign op values from matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Turbulence Analysis
il 23 Gen 2021
Commentato: Turbulence Analysis
il 23 Gen 2021
Hi all
Is there a way to assign for loop values from the matrix
for e.g. for i = x:y, here the value of x and y needs to be assigned rom the values present in the matrix, lets say A.. Is there a way to do this ??
0 Commenti
Risposta accettata
Walter Roberson
il 23 Gen 2021
Sure.
x = randi([0 1], 1, 50);
disp(char('0'+x))
locs = find(x)
for i = locs(13) : locs(17)-1
fprintf('x(%d) = %d\n', i, x(i));
end
5 Commenti
Walter Roberson
il 23 Gen 2021
A = [10:19, 120:150, 238:247];
mask = diff(A) == 1;
starts = A(strfind([0 mask], [0 1]));
for sequence = 1 : length(starts)
for i = starts(sequence)-5:starts(sequence)+5
do some calculations
end
filename = sprintf('results_%03d.mat', sequence);
save(filename, 'AppropriateVariable')
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!