how to replace double vectors from 0 to '000'
Mostra commenti meno recenti
hello every body; i am dealing with string and number how i can solve this problem: "In an assignment A(I) = B, the number of elements in B and I must be the same." "E_extrac_pro(ex_loop2)='000';" where numbers vector are double and contains:
numbers=[202;0 ;20;0;0;1013;10];
for ex_loop2=1:size(numbers)
if(numbers(ex_loop2)==0)
E_extrac_pro(ex_loop2)='000';
else
E_extrac_pro(ex_loop2)=numbers(ex_loop2);
end
end
Risposta accettata
Più risposte (1)
Image Analyst
il 14 Mag 2015
To mix strings and numbers in the same array, you'll have to use a cell array:
E_extrac_pro = cell(1, size(numbers));
for ex_loop2=1:size(numbers)
if(numbers(ex_loop2)==0)
E_extrac_pro{ex_loop2}='000';
else
E_extrac_pro{ex_loop2}=numbers(ex_loop2);
end
end
1 Commento
Mohamuud hassan
il 14 Mag 2015
Modificato: Mohamuud hassan
il 14 Mag 2015
Categorie
Scopri di più su Data Types in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!