How can I join two vectors (integer and decimal)?
显示 更早的评论
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 个评论
dpb
2018-11-24
How would you do it w/ pencil and paper if required to "show your work?"
Can you do that in ML?
Antonio Amor
2018-11-24
dpb
2018-11-24
Close but why the n? Your fraction is the tenth's location by the problem description.
What have you tried; have you worked through the "Getting Started" tutorials on Matlab syntax and operators (paying particular attention to array operations)?
Antonio Amor
2018-11-24
dpb
2018-11-24
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)???
采纳的回答
更多回答(1 个)
dpb
2018-11-24
C=A+B./10.^fix(log10(B)+1);
7 个评论
madhan ravi
2018-11-24
+1 efficient answer
dpb
2018-11-24
I didn't really want to post the solution but to try to lead OP towards it...but it appeared he bailed out early...
madhan ravi
2018-11-24
Clearly understood @dpb :)
madhan ravi
2018-11-24
That’s why your referred as a true motivator ❤️
madhan ravi
2018-11-26
:)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!