Only dataset that won't plot correctly
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Miriam Daughtery
el 26 de Dic. de 2019
Comentada: Miriam Daughtery
el 3 de En. de 2020
On all my other plots I have done with this code they have worked out fine, but for some reason this has not. Any advice?
This is my script for my plot:
function plot_CHL_data(data)
% function to plot the Giovanni data imported with load_giovanni_data
figure(1)
clf
plot(data.t,data.CHL,'.b-')
datetick('x')
ylabel('Chlorophyll Time Series', 'fontsize', 16)
xlabel('Date', 'fontsize', 16)
and this is my script to load the data:
function data=load_CHL_data(filename)
% function to load tide data from Giovanni
% input is the filename of the data file
% output is the date/time and SST from the data file
% tmp=tempory l=line
data.filename=filename;
fid=fopen(filename);
%Skips headerlines
for I=1:10
tmpl=fgetl(fid);
end
J=1;
while ischar(tmpl)
%5 strings
tmp=textscan(tmpl,'%s %f','Delimiter',',');
data.t(J)=datenum( cell2mat(tmp{1}) );
data.CHL(J)=tmp{2};
tmpl=fgetl(fid);
J=J+1;
end
%(-32767) == NaN;
fclose(fid);
I've also attached the file, as I think there might be something wrong with the data.
Thanks
0 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Dic. de 2019
Replace
%(-32767) == NaN;
with
data.CHL(data.CHL==-32767) = NaN;
5 comentarios
Walter Roberson
el 29 de Dic. de 2019
Yup, that's all.
function data=load_CHL_data(filename)
% function to load tide data from Giovanni
% input is the filename of the data file
% output is the date/time and SST from the data file
% tmp=tempory l=line
data.filename=filename;
fid=fopen(filename);
%Skips headerlines
for I=1:10
tmpl=fgetl(fid);
end
J=1;
while ischar(tmpl)
%5 strings
tmp=textscan(tmpl,'%s %f','Delimiter',',');
data.t(J)=datenum( cell2mat(tmp{1}) );
data.CHL(J)=tmp{2};
tmpl=fgetl(fid);
J=J+1;
end
data.CHL(data.CHL==-32767) = NaN;
fclose(fid);
together with
function plot_CHL_data(data)
% function to plot the Giovanni data imported with load_giovanni_data
figure(1)
clf
plot(data.t,data.CHL,'.b-')
datetick('x')
ylabel('Chlorophyll Time Series', 'fontsize', 16)
xlabel('Date', 'fontsize', 16)
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
