Only dataset that won't plot correctly
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Miriam Daughtery
le 26 Déc 2019
Commenté : Miriam Daughtery
le 3 Jan 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 commentaires
Réponse acceptée
Walter Roberson
le 26 Déc 2019
Replace
%(-32767) == NaN;
with
data.CHL(data.CHL==-32767) = NaN;
5 commentaires
Walter Roberson
le 29 Déc 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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
