Effacer les filtres
Effacer les filtres

Cant get array to be named something else

1 vue (au cours des 30 derniers jours)
jack knipler
jack knipler le 18 Mai 2016
Commenté : Stephen23 le 18 Mai 2016
Hi we have this script below but the only problem is that we can't get the function to be named anything other than'ans'which gives us problems later. Any help would be appreciated.Thank you
function [ ten ] = llen( data )
% This function takes an input array of time values, latitude values and longitude
% values, calculates the corresponding easting and northing values and
% outputs them as a horizontally concatenated array. Output = [time, east, north]
% Datum: WGS 84
% Input variables
t = data(:, 1); % time (first column)
lat = data(:, 2); % latitude (second column)
long = data(:, 3); % longitude (third column)
% All values taken from the 'Modified Longitude & Latitude' spreadsheet
% Datum Constants
a = 6378137; % equitorial radius
b = 6356752.31; % polar radius
k0 = 0.9996; % scale factor
e = sqrt(1-(b/a)^2); % eccentricity
e1sq = e^2/(1-e^2); % eccentricity prime squared
n = (a-b)/(a+b); % constant
% Meridional Arc Constants
A0 = a*(1-n+(5*n^2*1/4)*(1-n)+(81*n^4*1/64)*(1-n));
B0 = (3*a*n*1/2)*(1-n-(7*n^2*1/8)*(1-n)+(55*n^4*1/64));
C0 = (15*a*n^2*1/16)*(1-n+(3*n^2*1/4)*(1-n));
D0 = (35*a*n^3*1/48)*(1-n+(11*n^2*1/16));
E0 = (315*a*n^4*1/51)*(1-n);
% Calculation Constant
Sin1 = pi/(180*3600);
% Prerequisite Calculations
LZ = 31 + floor(long./6); % Long Zone
CM = 6.*(LZ)-183; % Long Zone CM
delta = (long - CM).*0.36; % Delta Long (sec)
z = (lat)*pi/180; % Latitude in radians
nu = a/((1-(e*sin(z)).^2).^(1/2)); % rcurv 2
% Calculating Meridional Arc 'S'
S = A0.*z - B0.*sin(2.*z) + C0.*sin(4.*z) - D0.*sin(6.*z) + E0.*sin(8.*z); % Meridional Arc
% UTM Coefficients
Ki = S.*k0;
Kii = nu*sin(z).*cos(z).*Sin1.^2*k0*(100000000)./2;
Kiii = ((Sin1.^4*nu*sin(z).*cos(z).^3)./24).*(5-tan(z).^2+9*e1sq.*cos(z).^2+4*e1sq.^2.*cos(z).^4)*k0*
(10000000000000000);
Kiv = nu*cos(z)*Sin1*k0*10000;
Kv =(Sin1*cos(z)).^3*(nu/6)*(1-tan(z).^2+e1sq*cos(z).^2)*k0*(1000000000000);
% Final Easting and Northing Calculations
easting = 500000 + (Kiv.*delta+Kv.*delta.^3); % Easting Calculation
rawnorthing = Ki + Kii.*delta.^2+Kiii.*delta.^4; % Raw Northing Calculation
if (rawnorthing < 0) %
northing = 10000000 + Ki + Kii.*delta.^2+Kiii.*delta.^4; % Conditional Northing Calculation
else %
northing = rawnorthing; %
end %
% Output final array
ten = [t easting northing] % Horizontally concatenate data and output it
end
  1 commentaire
Stephen23
Stephen23 le 18 Mai 2016
This very basic MATLAB usage is covered in the introductory tutorials:

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 18 Mai 2016
VariableNameThatYouWant = llen(TheInputData);
  2 commentaires
jack knipler
jack knipler le 18 Mai 2016
Thank you, which line would i add this into?
Walter Roberson
Walter Roberson le 18 Mai 2016
"we can't get the function to be named anything other than'ans'which gives us problems later"
You must have code that invokes llen now, perhaps something like
num = xlsread('SomeFile.xlsx');
llen(num)
You would change that to
num = xlsread('SomeFile.xlsx');
VariableThatYouWant = llen(num);

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by