to make a scaler from a vector
Show older comments
I have vector and I want to make him a scalat without functions
3 Comments
Birdman
on 23 Jan 2018
What do you mean? Give numeric examples.
ADIR MONSAN
on 23 Jan 2018
Guillaume
on 23 Jan 2018
What does without functions mean?
Just by writing
vec = [2 8 7]
you've already used the function horzcat.
Answers (2)
vec = [2 8 7];
num = vec * 10 .^ (length(vec)-1:-1:0).';
In your case this is
[2, 8, 7] * [100; 10; 1]
This works only, if the elements of the inputs are the digits 0 to 9 and if the length of the input is less than 16 digits. Otherwise the output cannot be stored in a double exactly.
Categories
Find more on Time Series Collections in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!