How can i get this function to work with this spreadsheet

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

2 Kommentare

Guillaume
Guillaume am 24 Jul. 2017
Bearbeitet: Guillaume am 24 Jul. 2017
It's unclear what you are asking.
On the one hand, we have a function with a meaningless name using variables with also meaningless names and absolutely no comment, so it's impossible to know what it's supposed to do. One thing is clear, it has nothing to do with spreadsheet
On the other hand, we have a spreadsheet (which we would have to download and open to even know what's in it).
No idea how the two relate to each other.
edit: and to top it off, the function defines its first output as L, yet never assigns anything to it, so it will result in an error every time it is called.
Stephen23
Stephen23 am 24 Jul. 2017
Bearbeitet: Stephen23 am 24 Jul. 2017
@Guillaume: it is clearly a super-secret test of super-intelligence, and anyone who cracks this super-cryptic question wins!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

ES
ES am 24 Jul. 2017
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

Weitere Antworten (0)

Gefragt:

am 24 Jul. 2017

Beantwortet:

ES
am 24 Jul. 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by