Plot is plotting very weird lines between points... Very confused!

5 ビュー (過去 30 日間)
mashtine
mashtine 2014 年 5 月 12 日
コメント済み: mashtine 2014 年 5 月 12 日
Hey everyone,
I attached the image and cell array and below is the code I use. When I use matlabs PLOTS tab and select the data it plots normally but I am not sure what is going on here. I do not have any INF or NaN values in the data:
inpdata = Turbineoutput_0813;
inpdata(cellfun(@(x) isnan(x), inpdata(:,7)),:)=[];
date = datenum(inpdata(:,1),'mm/dd/yyyy');
turb1out = cell2mat(inpdata(:,3));
turb2out = cell2mat(inpdata(:,4));
turb3out = cell2mat(inpdata(:,5));
turb4out = cell2mat(inpdata(:,6));
turb5out = cell2mat(inpdata(:,7));
figure;
plot(date,turb1out,'-k');
hold on
plot(date,turb2out,'--r');
hold on
plot(date,turb3out,'--b')
hold on
plot(date,turb4out,'--g');
hold on
plot(date,turb5out,'--c');
datetick('x','mm/yyyy','keeplimits');
ylabel('Daily turbine power output (kWh)');
I have made the code more detailed as I want to figure this out first and cannot find anything online about it.
  1 件のコメント
Sara
Sara 2014 年 5 月 12 日
Are the data in "date" ordered? Try using sort before plotting (sort both x and y of course).

サインインしてコメントする。

採用された回答

per isakson
per isakson 2014 年 5 月 12 日
編集済み: per isakson 2014 年 5 月 12 日
Change the line
date = datenum(inpdata(:,1),'mm/dd/yyyy');
to
date = datenum(inpdata(:,1),'dd/mm/yyyy');
.
Comment: datenum accepts month number 23
sdn = datenum('23/08/2008', 'mm/dd/yyyy' )
datestr( sdn, 'yyyy-mm-dd HH:MM:SS' )
returns
ans =
2009-11-08 00:00:00
  1 件のコメント
mashtine
mashtine 2014 年 5 月 12 日
Well that's embarrassing! Definitely spending too much time in front this computer!
Many thanks per isakson

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by