Why i get "Unexpected Matlab expression"?
Mostrar comentarios más antiguos
function [Drcode, timer, lat, lon, u, v] = read_drifter_1('cc1.dat' , '0');
%
% usage [Drcode, timer, lat, lon, u, v] = read_drifter_1(filename, plotflag)
% this routine reads the data from the .dat files produced by the Android
% Drifter application, and provides the data.
%
fid = fopen('cc1.dat');
A = fgetl(fid);
timer=[];
lat=[];
lon=[];
u = [];
v = [];
while ~feof(fid),
A = fgetl(fid);
s = findstr(A,' ');
N = length(s);
Rlat = str2num(A(s(1)+1:s(2)-1));
Rlon = str2num(A(s(2)+1:s(3)-1));
Ryy = str2num(A(s(5)+1:s(6)-1));
Rmm = str2num(A(s(6)+1:s(7)-1));
Rdd = str2num(A(s(7)+1:s(8)-1));
Rhh = str2num(A(s(8)+1:s(9)-1));
Rmin = str2num(A(s(9)+1:s(10)-1));
Rsec = str2num(A(s(10)+1:length(A)));
Rtime = datenum(Ryy, Rmm, Rdd, Rhh, Rmin, Rsec);
lat = [lat; Rlat];
lon = [lon; Rlon];
timer = [timer; Rtime];
end
%
% Start a quality control regarding times
% Sort the data in increasing time
[timer2, Itime] = sort(timer,'ascend');
lat2 = lat(Itime);
lon2 = lon(Itime);
% remove the data taken at exactly the same time (double records)
dt = diff(timer2);
J = find(dt > 0);
timer = timer2(J+1);
lat = lat2(J+1);
lon = lon2(J+1);
% %
fclose(fid);
Drcode = [];
if plotflag ~=0,
figure
plot(lon2, lat2,'.')
hold on
plot(lon, lat, 'o')
end
return
Christos
5 comentarios
Christos Chatzilaou
el 14 de Jun. de 2018
Try to define your function like this
function [Drcode, timer, lat, lon, u, v] = read_drifter_1(mystring , plotflag) %no ''
%do something with your input
fid = fopen(mystring);
...
end
and then you can call it:
read_drifter('cc1.dat',0)
Christos Chatzilaou
el 14 de Jun. de 2018
Christos Chatzilaou
el 14 de Jun. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics and Optimization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!