Comments (1)
For Matlab 2009
For an empty cell array, Matlab 2009 does return an empty cell array but a single empty cell. (use in AT/linopt)
%% 2009/2016
For Matlab 2016
MS = Empty array: 4-by-4-by-0
K>> num2cell(MS,[1 2])
Empty cell array: 1-by-1-by-0
En Matlab 2009
MS = Empty array: 4-by-4-by-0
K>> num2cell(MS,[1 2])
{}
%% Example to run if One wants to make an autotest
M = int16.empty(4,4,0)
M = Empty array: 4-by-4-by-0
B = num2cell(M, [1 2])
B = Empty cell array: 1-by-1-by-0
% SOLUTION for 2009
A quick fix : replace cell2num by commenting the following lines
% if isempty(a)
% c = {};
% return
% end
fullfile is given below:
function c = num2cell(a,dims)
%NUM2CELL Convert numeric array into cell array.
% C = NUM2CELL(A) converts numeric array A into cell array C by placing
% each element of A into a separate cell in C. The output array has the
% same size and dimensions as the input array. Each cell in C contains
% the same numeric value as its respective element in A.
%
% C = NUM2CELL(A, DIM) converts numeric array A into a cell array of
% numeric vectors, the dimensions of which depend on the value of the DIM
% argument. Return value C contains NUMEL(A)/SIZE(A,DIM) vectors, each of
% length SIZE(A, DIM). The DIM input must be an integer with a value from
% NDIMS(A) to 1.
%
% C = NUM2CELL(A, [DIM1, DIM2, ...]) converts numeric array A into a cell
% array of numeric arrays, the dimensions of which depend on the values
% of arguments [DIM1, DIM2, ...]. Given the variables X and Y, where
% X=SIZE(A,DIM1) and Y=SIZE(A,DIM2), return value C contains
% NUMEL(A)/PROD(X,Y,...) arrays, each of size X-by-Y-by-.... All DIMn
% inputs must be an integer with a value from NDIMS(A) to 1.
%
% NUM2CELL works for all array types.
%
% Use CELL2MAT or CAT(DIM,C{:}) to convert back.
%
% See also MAT2CELL, CELL2MAT% Clay M. Thompson 3-15-94
% Copyright 1984-2008 The MathWorks, Inc.
% $Revision: 1.18.4.5 $$Date: 2008/12/29 02:10:31 $ error(nargchk(1,2,nargin,'struct'));
% if isempty(a)
% c = {};
% return
% end
if nargin==1
c = cell(size(a));
for i=1:numel(a)
c{i} = a(i);
end
return
end% Size of input array
siz = [size(a),ones(1,max(dims)-ndims(a))];% Create remaining dimensions vector
rdims = 1:max(ndims(a),max(dims));
rdims(dims) = []; % Remaining dims% Size of extracted subarray
bsize = siz;
bsize(rdims) = 1; % Set remaining dimensions to 1% Size of output cell
csize = siz;
csize(dims) = 1; % Set selected dimensions to 1
c = cell(csize);% Permute A so that requested dims are the first few dimensions
a = permute(a,[dims rdims]);% Make offset and index into a
offset = prod(bsize);
ndx = 1:prod(bsize);
for i=0:prod(csize)-1,
c{i+1} = reshape(a(ndx+i*offset),bsize);
end
from at.
Related Issues (20)
- Frequency map with PyNAFF and patpass HOT 1
- wrong tune in atplot when lattice contains an IdTablePass (matlab) HOT 9
- lattice_pass modifies initial coordinates HOT 2
- lattice operators: function and documentation HOT 1
- pyat get_lifetime modifies the given refpts HOT 8
- atreforbit and rotation errors HOT 1
- Merging pull requests HOT 8
- AT does not compile with OpenMP=1 HOT 6
- atreduce transforms rbend in sbend HOT 3
- regular expression instead of fnmatch? HOT 15
- Observables and variables HOT 2
- get_unit32_index , get_bool_index names? HOT 12
- include fast_ring generation from a list of machine parameters (tunes, chromaticities, ac, U0, etc) HOT 5
- plot_beta help HOT 1
- plot_beta does not seem to have an option to display magnets names/indexes HOT 2
- modification to get_lifetime HOT 3
- atm2html not working HOT 2
- atSetRingProperties and cavpts side effect HOT 1
- Closed orbit in momentum aperture HOT 2
- Transverse Damping coming from EnergyLoss element HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from at.