Conversion of feet.inch to meter
Show older comments
How to convert a number with 5'.9''(5 feet 9 inch) to meter. I have tried convlength() but here the problem is after decimal it taking the number as unit "feet" not in "inch".
Actullay I have a data vector X = [6.5 5.9 5.9 3.4] where left side of the decimal are in unit "feet" and right side of the decimal are in "inch"
I have tried to create own function which is like this but this is not efficient way as I have to put a comma(,) in bettween two number. Can someone help me out.
function x = conv_feet(feet,inch)
inch1 = feet*12;
ans_2 = (inch+inch1)*0.0254; % to convert inch scale into meter scale
x = ans_2;
end
4 Comments
'Actullay I have a data vector X = [6.5 5.9 5.9 3.4] where left side of the decimal are in unit "feet" and right side of the decimal are in "inch"'
Please show how three feet and eleven inches would be represented in that vector.
"this is not efficient way as I have to put a comma(,) in bettween two number"
Abusing decimal numbers will make this task very inefficient. Better data design is strongly recommended.
DGM
on 5 Nov 2021
Maybe to make the point more clear, is 3.1000 equal to 3' 10.00", or is it 3' 1.000"?
If this vector is actually a string or char vector of numbers, that might be a different story, but if they're numeric, you're in trouble.
Sudhir Kumar
on 5 Nov 2021
"I have redisgned my code as follows and i got the answer"
I doubt that, because so far you have inconsistent handling of inches. Compare:
x = [5.01,5.09,5.9,5.11]
feet_1= floor(x);
inch = x - feet_1;
inch = inch*10
Your very poor data design is causing you problems, which your code does not handle.
Accepted Answer
More Answers (0)
Categories
Find more on External Language Interfaces 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!