concatenate column values in a vector
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Elysi Cochin
le 20 Nov 2019
Réponse apportée : Steven Lord
le 20 Nov 2019
i have a vector
v1 = [ 1,0,1,0] (dim 1x4 double)
i wanted to join the values in v1 to a new variable
v2 = [1010] (dim 1x1 double)
how to do so
0 commentaires
Réponse acceptée
KALYAN ACHARJYA
le 20 Nov 2019
Modifié(e) : KALYAN ACHARJYA
le 20 Nov 2019
Simpler way:
v=[1,0,1,0];
result=str2num(sprintf('%1d',v))
Result:
result =
1010
>>
0 commentaires
Plus de réponses (2)
Erivelton Gualter
le 20 Nov 2019
You can use the following line of code:
v2 = sum(v1*diag(10.^(length(v1)-1:-1:0)));
0 commentaires
Steven Lord
le 20 Nov 2019
Treat v1 as the coefficients of a polynomial and evaluate that polynomial for x = 10.
v1 = [ 1,0,1,0];
v2 = polyval(v1, 10)
0 commentaires
Voir également
Catégories
En savoir plus sur Polynomials dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!