Using meshgrid from cell array error - "Undefined function full for input arguments of type cell"
Show older comments
I am getting an error when trying to use the meshgrid function after creating an array from a structure using a for loop.
if true
%function (A,B) = 'Plot Output'
% This function takes input from the numbers of observation points for the % TABOO input and corresponds the observation point with the calculations % on the output files 'rate.his' and 'disp.his'
B = load ('obspoints.txt'); num_obs = length(B);
%num_obs = 11;
fid = fopen('rate.his') ;
if fid == -1
disp ('File open not working')
else
disp('File open worked!')
S = textscan(fid,'%s','delimiter','\n') ; %scans text
S = S{1} ;
%get locations where # not present
qwe= strfind(S, '#'); %locates string '#'
qwe = find((cellfun('isempty',qwe)));
%create new array sans '#'
qwer = cell2mat(cellfun(@str2num,S(qwe),'un',0)) ;
qwerl = length(qwer);
closeresult = fclose(fid);
if closeresult == 0
disp('File Close worked')
else
disp('File Close failure')
end
end
for n= 1:num_obs - 1
zxa = n + (n-1)*10; %functions which give the column interval on the above
%matrice which correspond to each time stamp on the observation point
zxb = n + (n-1)*10 + 10;
rate(n).long = B(n,2);
rate(n).lat = B(n,1);
rate(n).time = qwer(zxa:zxb,1);
rate(n).dvert = qwer(zxa:zxb,2);
rate(n).dnorth = -1*qwer(zxa:zxb,3);
rate(n).deast = qwer(zxa:zxb,4);
rate(n).dgeoid = qwer(zxa:zxb,5);
rate(n).mass = qwer(zxa:zxb,6);
end
cell = struct2cell(rate);
% After the structure has been created, different outputs can be easibly % accessed, but must be turned back into a cell from the structure, and % a foor loop is used to fill up the arrays so the meshgrid function can be % used
for n= 1:num_obs - 1
long(n) = cell(1,:,n);
lat(n) = cell(2,:,n);
dvert(n)= cell(4,:,n);
end
[X,Y] = meshgrid(long,lat);
% code
end
the error message is:
Undefined function 'full' for input arguments of type 'cell'.
Error in meshgrid (line 56) xrow = full(x(:)).'; % Make sure x is a full row vector.
1 Comment
Jan
on 27 Mar 2017
Using "cell" as a name of a variable shadows the builtin function with the same name. This does not cause the problems here, but it is a frequent source of bugs.
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!