个人资料
最新文章
文章分类
归档
正文

Debski

(2009-04-10 02:23:28) 下一个

function varargout = Force_1(varargin)
% FORCE_1 M-file for Force_1.fig
%      FORCE_1, by itself, creates a new FORCE_1 or raises the existing
%      singleton*.
%
%      H = FORCE_1 returns the handle to a new FORCE_1 or the handle to
%      the existing singleton*.
%
%      FORCE_1('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FORCE_1.M with the given input arguments.
%
%      FORCE_1('Property','Value',...) creates a new FORCE_1 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Force_1_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Force_1_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help Force_1

% Last Modified by GUIDE v2.5 19-Feb-2009 19:44:21

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Force_1_OpeningFcn, ...
                   'gui_OutputFcn',  @Force_1_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Force_1 is made visible.
function Force_1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Force_1 (see VARARGIN)

% Choose default command line output for Force_1
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Force_1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Force_1_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double
input = str2num(get(hObject,'String'));
if(isempty(input))
    set(hObject,'String','0')
end
guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a1=get(handles.edit1,'String');
if(isempty(a1))
    rox=0;
else
   rox=str2num(a1);
end
a2=get(handles.edit2,'String');
if(isempty(a2))
    roy=0;
else
    roy=str2num(a2);
end
a3=get(handles.edit3,'String');
if(isempty(a3))
    roz=0;
else
     roz=str2num(a3);
end
a4=get(handles.edit4,'String');
if(isempty(a4))
    xx=0;
else
    xx=str2num(a4);
end
a5=get(handles.edit5,'String');
if(isempty(a5))
    yy=0;
else
    yy=str2num(a5);
end
a6=get(handles.edit6,'String');
if(isempty(a6))
    zz=0;
else
    zz=str2num(a6);
end
d=[xx,yy,zz];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute rotational matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rox=rox*3.1416/180;
roy=roy*3.1416/180;
roz=roz*3.1416/180;
% rotational matrix
Rox=[1,0,0; 0, cos(rox),-sin(rox);0,sin(rox), cos(rox)]; 
Roy=[cos(roy),0,sin(roy); 0, 1, 0; -sin(roy),0, cos(roy)];
Roz=[cos(roz), -sin(roz), 0; sin(roz), cos(roz), 0; 0, 0,1];
R=Roz*Roy*Rox-eye(3,3);  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% define local system related to ABAQUS global system
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ox=[0.9938 -0.021 -0.109];
oy=[0.0201 0.9991 -0.0091];
oz=[0.073 0.0076 0.9973];
oxyz=[ox(1),oy(1), oz(1); ox(2),oy(2),oz(2);ox(3),oy(3),oz(3)];
% original point for local system
o_local=[53.9952,92.3274,-99.0928];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       compute elastic forces of ligaments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% femur fixed, its insertion is marked with 1
% tibia fibula move, its insertion is marked with 2

% AM in ACL ligament, L1_AM is insertion in femur
%                     L2_AM is insertion in tibia
%                     L3_AM is new position of NN2_AM after movement
L0_AM=25.1;
% coordinates in ABAQUS global system
L1_AM=[43.824501,107.9356,-99.8647003];
L2_AM=[51.4678993,90.4445038,-124.593102];
% compute the new position in local system
L3=oxyz*R*inv(oxyz)*(L2_AM'-o_local')+oxyz*d';
L3_AM=L3'+L2_AM;
xx1=L1_AM(1)-L3_AM(1);
yy1=L1_AM(2)-L3_AM(2);
zz1=L1_AM(3)-L3_AM(3);
dx_AM=sqrt(xx1^2+yy1^2+zz1^2)-L0_AM;
dx=dx_AM;
if dx <0
  F_AM=0;
else
  F_AM=(1.1671+3.065*dx+2.6096*dx^2+0.99953*dx^3-0.06155*dx^4)*0.54;
end
if F_AM < 0
    F_AM=0;
end

% PL in ACL ligament, L1_PL is insertion in femur
%                     L2_PL is insertion in tibia
%                     L3_PL is new position of L2_AM after movement
L0_PL=27.3;
% ABAQUS global coordinates
L1_PL=[43.824501, 107.9356,-99.8647003];
L2_PL=[58.4379005, 86.5944977,-125.948196];
% compute the new positon in local system
L3=oxyz*R*inv(oxyz)*(L2_PL'-o_local')+oxyz*d';
L3_PL=L3'+L2_PL;
xx2=L1_PL(1)-L3_PL(1);
yy2=L1_PL(2)-L3_PL(2);
zz2=L1_PL(3)-L3_PL(3);
dx_PL=sqrt(xx2^2+yy2^2+zz2^2)-L0_PL;
dx=dx_PL;
if dx < 0
  F_PL=0;
else
  F_PL=(1.1671+3.065*dx+2.6096*dx^2+0.99953*dx^3-0.06155*dx^4)*0.46;
end
if F_PL < 0
    F_PL =0;
end
   
cosa=(xx1*xx2+yy1*yy2+zz1*zz2)/sqrt(zz1^2+yy1^2+zz1^2)/sqrt(xx2^2+yy2^2+zz2^2);
F_ACL=sqrt(F_AM^2+F_PL^2+2*F_AM*F_PL*cosa);
F_ACL=round(F_ACL*100)/100;


% LCL ligament, L1_LCL is insertion in femur
%               L2_LCL is insertion in tibia
%               L3_LCL is new position of L2_LCL after movement
L0_LCL=49.5;
% ABAQUS global coordinates
L1_LCL=[11.0170997, 100.830022,-98.3675029];
L2_LCL=[3.89059997, 109.567703,-156.951706];
% compute the new position in local system
L3=oxyz*R*inv(oxyz)*(L2_LCL'-o_local')+oxyz*d';
L3_LCL=L3'+L2_LCL;
dx_LCL=sqrt((L1_LCL(1)-L3_LCL(1))^2+(L1_LCL(2)-L3_LCL(2))^2+(L1_LCL(3)-L3_LCL(3))^2)-L0_LCL;
dx=dx_LCL;
if dx <0
  F_LCL=0;
else
  F_LCL=2.287-1.573*dx+4.8886*dx^2+0.18416*dx^3-0.040783*dx^4;
end
if F_LCL < 0
    F_LCL=0;
end
F_LCL=round(F_LCL*100)/100;

% MCL ligament, L1_MCL is insertion in femur
%               L2_MCL is insertion in tibia
%               L3_MCL is new position of L2_MCL after movement
L0_MCL=81;
% ABAQUS global system
L1_MCL=[94.1690985,80.2150008,-95.5930022];
L2_MCL=[73.5178986, 80.1570969, -165.155807];
% compute the new postion in local system
L3=oxyz*R*inv(oxyz)*(L2_MCL'-o_local')+oxyz*d';
L3_MCL=L3'+L2_MCL;
dx_MCL=sqrt((L1_MCL(1)-L3_MCL(1))^2+(L1_MCL(2)-L3_MCL(2))^2+(L1_MCL(3)-L3_MCL(3))^2)-L0_MCL;
dx=dx_MCL;
if dx < 0
   F_MCL=0;
else
   F_MCL=2.2548-7.3118*dx+9.9815*dx^2+1.4185*dx^3-0.21652*dx^4;
end
if F_MCL < 0
    F_MCL=0;
end
F_MCL=round(F_MCL*100)/100;

% PCL ligament, L1_PCL is insertion in femur
%               L2_PCL is insertion in tibia
%               L3_PCL is new position of L2_PCL after movement
L0_PCL=32;
% ABAQUS global system
L1_PCL=[62.672699, 99.9365997, -105.149399];
L2_PCL=[42.3188019, 107.903603, -132.239502];
% compute the new position in local system
L3=oxyz*R*inv(oxyz)*(L2_PCL'-o_local')+oxyz*d';
L3_PCL=L3'+L2_PCL;
dx_PCL=sqrt((L1_PCL(1)-L3_PCL(1))^2+(L1_PCL(2)-L3_PCL(2))^2+(L1_PCL(3)-L3_PCL(3))^2)-L0_PCL;
dx=dx_PCL;
if dx < 0
  F_PCL=0;
else
  F_PCL=3.1947+0.53853*dx+0.44628*dx^2+3.6632*dx^3-0.3102*dx^4;
end
F_PCL=round(F_PCL*100)/100;
if F_PCL < 0
     F_PCL=0;
end
% OUTPUT
set(handles.text18,'String',num2str(F_ACL));
set(handles.text19,'String',num2str(F_PCL));
set(handles.text20,'String',num2str(F_LCL));
set(handles.text21,'String',num2str(F_MCL));
guidata(hObject,handles);


[ 打印 ]
阅读 ()评论 (5)
评论
目前还没有任何评论
登录后才可评论.