For loop in string array
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Aakash Soni
il 19 Gen 2023
Commentato: Aakash Soni
il 19 Gen 2023
Hello Matlab Community,
How can I loop though my string array to get indexes? Here is my code using for loop but it creates blank matix after running a for loop.
str = importfile("imageTimeline1.xlsx");
% individual data collection
Ind_1_start = find(contains(str,'Stimulus 1 Data'));
Ind_1_end = find(contains(str,'Questionnair 1 Data'));
Ind_2_start = find(contains(str,'Stimulus 2 Data'));
Ind_2_end = find(contains(str,'Questionnair 2 Data'));
% using for loop to collect index information
for ii = 1:20
Ind_start{:,ii} = find(contains(str,['Stimulus' num2str(ii) 'Data']));
Ind_end{:,ii} = find(contains(str,['Questionnair' num2str(ii) 'Data']));
end
Thank you,
Aakash.
0 Commenti
Risposta accettata
Walter Roberson
il 19 Gen 2023
['Stimulus' num2str(ii) 'Data']
that does not generate spaces between the word and the number.
I suggest that you use sprintf()
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!