How can I join two vectors (integer and decimal)?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Antonio Amor
le 24 Nov 2018
Commenté : madhan ravi
le 26 Nov 2018
I have two vectors for the same number (type double): one is the integer part and the other is the decimal part. Both the same lenght. Can I join them in one vector?
I have A = [1 2 3 4 5]; B = [6 7 8 9 10];
I want a vector C = [1.6 2.7 3.8 4.9 5.10];
Thanks in advance.
5 commentaires
dpb
le 24 Nov 2018
Ah! I didn't notice the actual numbers...good catch! I was going for the specific trivial answer.
Look up "dot" operators by reading section on Array vs. Matrix Operations for how to handle the array "the Matlab way".
How can you compute the magnitude of the values to which need respectifve power of B (a specific transcendental function may come to mind)???
Réponse acceptée
madhan ravi
le 24 Nov 2018
Modifié(e) : madhan ravi
le 24 Nov 2018
One nasty way which is highly discouraged:
>> A = string([1 2 3 4 5]);
B = string([6 7 8 9 10]);
C=strcat(A,'.',B);
C=str2double(C)
C =
1.6000 2.7000 3.8000 4.9000 5.1000
>>
2 commentaires
madhan ravi
le 24 Nov 2018
Anytime :) , MATLAB makes life a lot more easier so take your classes seriously , it will help you in your higher studies, HAPPY MATLAB(ing).
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!