MATLAB: How can i get this function to work with this spreadsheet

functionspreadsheet

function [L,B,C] = xyz2lbc(Xc,Yc,Zc,R)
if( (length(Xc) ~= length(Yc)) | (length(Xc) ~= length(Zc)) )
error('size');
end
if(nargin == 3)
R = zeros(1,length(Xc)-2);
elseif(length(R) == 1)
R = ones(1,length(Xc)-2).*R;
elseif(length(R) ~= length(Xc)-2)
error('R not match');
end
for i = 1:length(Xc)-2
V1 = [Xc(i)-Xc(i+1) ; Yc(i)-Yc(i+1) ; Zc(i)-Zc(i+1)];
V2 = [Xc(i+2)-Xc(i+1) ; Yc(i+2)-Yc(i+1) ; Zc(i+2)-Zc(i+1)];
V1l = Vlength(V1);
V2l = Vlength(V2);
C(i) = pi - acos(dot(V1,V2) / (V1l*V2l));
planeV(i,:) = cross(V1,V2)';
if(i>1)
Y(i) = Y(i) - R(i)*tan(C(i)/2);
Y(i+1) = V2l - R(i)*tan(C(i)/2);
PV1l = Vlength(planeV(i-1,:));
PV2l = Vlength(planeV(i,:));
s=sign(V1 .* cross(planeV(i-1,:),planeV(i,:))');
B(i) = acos(dot(planeV(i-1,:),planeV(i,:))/(PV1l*PV2l))*s(1);
else
Y(i) = V1l - R(i)*tan(C(i)/2);
Y(i+1) = V2l - R(i)*tan(C(i)/2);
B(i) = 0;
end
end

Best Answer

The xls file has values for Xc, Yc and Zc. You have to read it (using xlsread) and call your function. The other argument (R) you can ignore in the call. If it is ignored, it is generated by the function automatically.
%%Import the data
[~, ~, raw] = xlsread('TABLE.xls','TABLE');
raw(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),raw)) = {''};
%%Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),raw); % Find non-numeric cells
raw(R) = {NaN}; % Replace non-numeric cells
%%Create output variable
data = reshape([raw{:}],size(raw));
%%Allocate imported array to column variable names
Xc = data(:,1);
Yc = data(:,2);
Zc = data(:,3);
[L,B,C] = xyz2lbc(Xc,Yc,Zc);%Call the function