That’s a fairly complicated file to read, but this works:
fidi = fopen('heightweight.txt');
D = textscan(fidi, '%f%f', 'HeaderLines',8, 'TreatAsEmpty',{'\' '}'}, 'EndOfLine','\r\n');
fclose(fidi);
inch = D{1};
inch = inch(~isnan(inch));
pound = D{2};
pound = pound(~isnan(pound));
Then expressing your function (saving it to IPtoCK.m) as:
function [centimeter,kilogram]=IPtoCK(inch,pound)
centimeter=(inch.*2.54);
kilogram=(pound.*0.4536);
end
and calling it as:
[centimeter,kilogram]=IPtoCK(inch,pound)
is all you need.
Best Answer