When I try simple statistics function normpdf, it does not work.

6 views (last 30 days)
Anjali Mishra
Anjali Mishra on 28 Dec 2021
Edited: Image Analyst on 28 Dec 2021
My Matlab Master License Number is 3******2
Company Name: Rivian Automotive
  1. When trying normpdf, I get following error
'normpdf' requires Statistics and Machine Learning Toolbox
2. when trying to convert GPS(lat, long, alt) to ECEF I tried function xcframe, I get following error:
Unrecognized function or variable 'xcframe'
Can you please help me with what toolbox I am missing to use these functions for my above license?

Accepted Answer

Meg Noah
Meg Noah on 28 Dec 2021
You can write your own normpdf if that is all you need. Here it is as an anonymous function (see: https://www.originlab.com/doc/LabTalk/ref/Normpdf-func)
normpdf = @(x,mu,sigma) (1.0./(sqrt(2*pi).*sigma))*exp(-0.5*((x-mu)./sigma).^2);
GPS is typically referenced to the WGS84 Earth Ellipsoid. You can readily implement the algorithm outlined in the Geographic coordinate conversion - From geodetic to ECEF coordinates wikipedia page:
where Φ is latitude, λ is longitude, and
Use a site like this online calculator to spot verify your code (check the stressing points like poles, equator as well as some reference points: https://www.oc.nps.edu/oc2902w/coord/llhxyz.htm
This code needs some range checking and array checking to be robust:
function [x_m,y_m,z_m] = convLLA2ECEF(lat_degN,lon_degE,alt_m)
%% *purpose*
% convert WGS84 Lat, Lon, Alt to ECEF X, Y, Z
%% *inputs*
% lat_degN - [degrees North] latitude values
% lon_degE - [degrees East] longitude values
% alt_m - [m] height Above Mean Sea Level (WGS84 Ellipsoid Reference)
%% *outputs*
% x_m - [m] ECEF x values
% y_m - [m] ECEF y values
% z_m - [m] ECEF z values
%% *start*
WGS84_e2 = 6.69437999014e-3; % [unitless] square of WGS84 1st eccentricity
WGS84_a = 6378137.0; % [m] equatorial radius defined by WGS84 ellipsoid
clat = cosd(lat_degN);
slat = sind(lat_degN);
clon = cosd(lon_degE);
slon = sind(lon_degE);
N = WGS84_a ./ sqrt(1.0 - WGS84_e2 * slat .* slat);
x_m = (N + alt_m) .* clat .* clon;
y_m = (N + alt_m) .* clat .* slon;
z_m = (N .* (1.0 - WGS84_e2) + alt_m) .* slat;
return
end

More Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 28 Dec 2021
Your MATLAB package does not have a toolbox - Statistics and Machine Learning Toolbox
Thus, such err is prompted.
Check what toolboxes are installed in your computer using this command in the command window:
>> ver
You may also check any fcns of matlab whether available or not by using the following command, e.g. using this command in the command window:
>> which normpdf

Community Treasure Hunt

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

Start Hunting!