Only dataset that won't plot correctly
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2019년 12월 26일
Replace
%(-32767) == NaN;
with
data.CHL(data.CHL==-32767) = NaN;
댓글 수: 5
Walter Roberson
2019년 12월 29일
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)
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
