Skip to content

Commit

Permalink
Matlab R2024b some "Analyze Code" fixes
Browse files Browse the repository at this point in the history
- "length(X)==1" and "numel(X)==1" changed to "isscalar(X)".
- Assigned but unused parameters replaced by "~".
- Silence a warning about unreachable test code (if true, X, else, Y; end).
- Remove output argument for function which never set this argument
  ('info' in onera_desp_lib_load.m).
  • Loading branch information
thomas-nilsson-irfu committed Dec 11, 2024
1 parent 921b949 commit 5f902fb
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_coord_trans.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
error('Argument X must be size n x 3 in %s',mfilename);
end
ntime = r;
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
4 changes: 2 additions & 2 deletions matlab/onera_desp_lib_empiricallstar.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand All @@ -62,7 +62,7 @@
onera_desp_lib_empiricallstar(kext,options,matlabd(ii),maginput(ii,:),Lm(ii),J(ii));
end
else
[iyear,idoy,UT] = onera_desp_lib_matlabd2yds(matlabd);
[iyear,idoy,~] = onera_desp_lib_matlabd2yds(matlabd);
LstarPtr = libpointer('doublePtr',Lstar);
maginput = maginput';
% expand arrays
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_find_foot_point.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_find_magequator.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_find_mirror_point.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
4 changes: 2 additions & 2 deletions matlab/onera_desp_lib_fly_in_afrl_crres.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end
end

if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,length(x1));
end

Expand Down Expand Up @@ -115,7 +115,7 @@
Flux = nan(Nmax,1);
if isempty(Ap15)
Ap15 = nan(1,Nmax);
elseif length(Ap15)==1
elseif isscalar(Ap15)
Ap15 = repmat(Ap15,1,Nmax);
else
Ap15 = [Ap15(:)', nan(1,Nmax-ntime)];
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_fly_in_nasa_aeap.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
end
end

if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,length(x1));
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_get_bderivs.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end
maginput = onera_desp_lib_maginputs(maginput); % NaN to baddata
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_get_crres_flux.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
Flux = nan(Nmax,1);
if isempty(Ap15)
Ap15 = nan(1,Nmax);
elseif length(Ap15)==1
elseif isscalar(Ap15)
Ap15 = repmat(Ap15,1,Nmax);
else
Ap15 = [Ap15(:)', nan(1,Nmax-ntime)];
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_get_field.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_get_hemi.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end
maginput = onera_desp_lib_maginputs(maginput); % NaN to baddata
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_get_mlt.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

ntime = size(xGEO,1);

if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end

Expand Down
6 changes: 3 additions & 3 deletions matlab/onera_desp_lib_grid_lstar.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
grid.NLON = length(grid.lon);
[grid.LAT,grid.LON] = meshgrid(grid.lat,grid.lon);
grid.N = numel(grid.LAT);
[Bgeo,B] = onera_desp_lib_get_field(kext,options,'RLL',repmat(matlabd,grid.N,1),ones(grid.N,1),grid.LAT(:),grid.LON(:),repmat(maginput,grid.N,1));
[Bgeo,~] = onera_desp_lib_get_field(kext,options,'RLL',repmat(matlabd,grid.N,1),ones(grid.N,1),grid.LAT(:),grid.LON(:),repmat(maginput,grid.N,1));
rhat = [cosd(grid.LAT(:)).*cosd(grid.LON(:)), cosd(grid.LAT(:)).*sind(grid.LON(:)), sind(grid.LAT(:))];
Bdotr = reshape(sum(rhat.*Bgeo,2),size(grid.LAT));
grid.partialPhi = cumtrapz(sind(grid.lat),Bdotr,2);
Expand Down Expand Up @@ -570,7 +570,7 @@
kext = '';
maginput = [];
else % T89, Kp=2
field_model = 'T89, Kp=2';
field_model = 'T89, Kp=2'; %#ok <UNRCH>
options = {};
kext = 'T89';
maginput = onera_desp_lib_maginputs(2); % Kp=2
Expand All @@ -587,7 +587,7 @@
extras{end+1} = 'G'; % force Gauss in Bunit
iplot = 1:length(z); % which z to plot
case 'a0' % a0 grid
z = [2:2:90]; % deg
z = 2:2:90; % deg
iplot = length(z):-2:1; % which z to plot
case 'Bm' % Bmirror grid
z = [0.3e3;1e3;3e3;10e3;30e3]; % nT
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_load.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function info = onera_desp_lib_load(libfile,headerfile)
function onera_desp_lib_load(libfile,headerfile)
%***************************************************************************************************
% Copyright 2009, T.P. O'Brien
%
Expand Down
4 changes: 2 additions & 2 deletions matlab/onera_desp_lib_lstar_phi.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@

onera_desp_lib_load;

if (numel(matlabd)==1) && (numel(in)>1)
if (isscalar(matlabd)) && (numel(in)>1)
matlabd = repmat(matlabd,size(in));
end

if (numel(in)==1) && (numel(matlabd)>1)
if (isscalar(in)) && (numel(matlabd)>1)
in = repmat(in,size(matlabd));
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_maginputs.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
% NaN's are replaced with the library bad data value, -1e31
baddata=-1.0E31;

if (length(varargin)==1) && (size(varargin{1},2)==25) % first/only arg is maginputs
if (isscalar(varargin)) && (size(varargin{1},2)==25) % first/only arg is maginputs
maginputs = varargin{1};
else % multiple args
n = max(arrayfun(@(x)length(x{1}),varargin)); % get length of longest list
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_make_lstar_core.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
if size(maginput,1) ~= ntime
maginput = repmat(maginput,ntime,1);
end
if length(matlabd)==1
if isscalar(matlabd)
matlabd = repmat(matlabd,ntime,1);
end
maginput = onera_desp_lib_maginputs(maginput); % NaN to baddata
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_msis.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@

nanpad = nan(Nmax-N,1);
date = [date(:);nanpad];
[iyear,idoy,UT] = onera_desp_lib_matlabd2yds(date);
[~,idoy,UT] = onera_desp_lib_matlabd2yds(date);
Ap = [Ap;repmat(nanpad,1,size(Ap,2))];
if WhichAp==1
Ap = [Ap,nan(Nmax,6)]; % add extra columns
Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_multi_Lstar_hmin.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function write_inputs(filename,kext,options,sysaxes,dates,x1,x2,x3,alpha,maginpu

ntimes = numel(dates);

if numel(alpha)==1
if isscalar(alpha)
alpha = repmat(alpha,ntimes,1);
end

Expand Down
2 changes: 1 addition & 1 deletion matlab/onera_desp_lib_sgp4_tle.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
% 6: longitude (deg)
% 26/01/2007 0: 4:59.999982 2007.06850263 20096.506220 -0.002629 -124.124210
% 26/01/2007 0:10: 0.000004 2007.06851218 20096.506204 -0.002508 -122.858292
[dd,mm,yyyy,hh,minute,ss,decyear,alt,lat,lon] = textread(OutFile,'%d/%d/%d %d:%d:%f %f %f %f %f');
[dd,mm,yyyy,hh,minute,ss,~,alt,lat,lon] = textread(OutFile,'%d/%d/%d %d:%d:%f %f %f %f %f');

pos.date = datenum(yyyy,mm,dd,hh,minute,ss);
pos.alt = alt;
Expand Down

0 comments on commit 5f902fb

Please sign in to comment.