How can i extract string of a cell array with an indexing in a for loop ?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
gaylord durand
il 26 Giu 2020
Commentato: gaylord durand
il 1 Lug 2020
Here is my problem :
I use webcamlist to get all the devices names, then i want to extract each name into a "variable" that can be indexing in a for loop.
My code is the following one :
list = webcamlist;
[Rangenumb,Colnumb]= size(webcamlist);
for i = 1 : Rangenumb;
x(i) = extractAfter(list{i,1},0);
end
I get this warning :
Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side.
Error in listwebcam (line 5)
x(i) = extractAfter(list{i,1},0);
I know that a fonction x(i) is not suitable but i don't find a solution to create an indexed variable that extract each name like : x1 = 'Usb Camera' , x2 = ' HP Camera ' , etc....
Thanks in advance for the replies.
0 Commenti
Risposta accettata
madhan ravi
il 26 Giu 2020
list = webcamlist;
[Rangenumb,Colnumb]= size(webcamlist);
x = cell(1, Rangenumb);
for ii = 1 : Rangenumb;
x{ii} = extractAfter(list{ii,1},0);
end
celldisp(x)
Più risposte (1)
Walter Roberson
il 26 Giu 2020
x = string(webcamlist);
Now x(1), x(2) and so on.
If you are trying to put them into seperate variables x1, x2, and so on... then don't.
Vedere anche
Categorie
Scopri di più su Parallel for-Loops (parfor) 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!