Sometimes it is necessary to estimate values that you can\'t measure easily from
ID: 3757723 • Letter: S
Question
Sometimes it is necessary to estimate values that you can't measure easily from values that you can. For example, bone traits can usually only be measured accurately using non-invasive techniques like x-ray, CT scan, or MR1. This is expensive and time consuming, but if you can measure a large sample of people using these techniques, you can regress the data to develop an equation which relates (for example) a person's height to their tibia length. Two files have been uploaded: MaleTibiaData.txt and FemaleTibiaData.txt. They contain actual subject data from men and women. The first column is each person's height, h (in cm), the second column is their tibia length (in mm) measured from a CT scan. Write a function with header [tibl] = myTibia Length (height, sex) , where height is a user's height in cm and sex is either "m" or "f" The output argument will be a 2 TIMES 1 vector where tibL(l) = a1 + a2 h tibL( 2) =a1 + a2h + a3h2
Explanation / Answer
%Script file
MaleData=load('MaleTibiaData.txt');
FemaleData=load('FemaleTibiaData.txt');
% first column person height in cm
% second column is tibia length in mm
if MaleData<1 or FemaleData<1
disp('Tibia File open not successful');
exit(0);
end
MaleHeight=zeros(100,1);
MaleTibia=zeros(100,1);
sex='M';
countM=1;
while ~feof(MaleData)
MaleHeight(countM)=fscanf(MaleData,'%f',1);
[tiBL]=myTibiaLength(MaleHeight(countM),sex);
MaleTibia(countM)=tiBL(2);
countM=countM+1;
end
p = polyfit(MaleHeight,MaleTibia,2);
f1 = polyval(p,MaleHeight);
figure
plot(MaleHeight,MaleTibia);
hold on;
title('Male Height Vs Male Tibia');
plot(MaleHeight,f1);
xlabel('x-axis');
ylabel('y-axis');
hold off;
fclose(MaleData);
FemaleHeight=zeros(100,1);
FemaleTibia=zeros(100,1);
sex='F';
countF=1;
while ~feof(FemaleData)
height(countF)=fscanf(FemaleData,'%f',1);
[tiBL]=myTibiaLength(height(countF),sex);
MaleTibia(countM)=tiBL(2);
countF=countF+1;
end
p = polyfit(FemaleHeight,FemaleTibia,2);
f1 = polyval(p,FemaleHeight);
figure
plot(FemaleHeight,FemaleTibia);
hold on;
title('Female Height Vs Female Tibia');
plot(FemaleHeight,f1);
xlabel('x-axis');
ylabel('y-axis');
hold off;
fclose(FemaleData);
%=============================================
% function myTibiaLength.m
[tibL]=myTibiaLength(height,sex)
%height - user height in cm
%sex - m or f
%output is 2x1 vector
tibL=zeros(2,1);
tibL(1)=a1+(a2*height);
tibL(2)=a1+(a2*height)+(a3*height^2);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.