lets say i have a vector [1,1,1]
is there a function that can convert this to the number 111 ?
Direct link to this comment:
What should be done if the vector includes values greater than 9?
If the vector starts with values that are 0, what should be the result ?
the vector does not contain values greater than 9.
if it has 0 to the left it ignores them - 009=9, 012=12 etc.
i could write a for loop that calculates this but i was wondering if there is a function.
No products are associated with this question.
Direct link to this answer:
a = randi(9,1,5);
your_num = sscanf(sprintf('%d',a),'%d');
alt_sol = sum(a.*repmat(10,1,numel(a)).^(numel(a)-1:-1:0));
MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Opportunities for recent engineering grads.
New to MATLAB?
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a location from the following list:
See all countries