Skip to main content
Code Review

Return to Question

Notice removed Draw attention by Community Bot
Bounty Ended with padawan's answer chosen by Community Bot
Tweeted twitter.com/#!/StackCodeReview/status/166438601503145985
improved formatting
Source Link
palacsint
  • 30.3k
  • 9
  • 82
  • 157

Code to generate Generate graph in Matlab - review for best practice or speedup.

I use this matlabMatlab code:

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

to generate this graph:

graph

from data like:

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlabMatlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

Code to generate graph in Matlab - review for best practice or speedup.

I use this matlab code:

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

to generate this graph:

graph

from data like:

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

Generate graph in Matlab

I use this Matlab code:

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

to generate this graph:

graph

from data like:

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of Matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R...

I use this matlab code...:

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

Toto generate this graphhttp://www.cs.rhul.ac.uk/home/joseph/productivityFiles/inbox7day.jpeg ,:

graph

from data like:

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

I use this matlab code...

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

To generate this graphhttp://www.cs.rhul.ac.uk/home/joseph/productivityFiles/inbox7day.jpeg , from data like

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

I use this matlab code:

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

to generate this graph:

graph

from data like:

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

Notice added Draw attention by Joe
Bounty Started worth 50 reputation by Joe
Source Link
Joe
  • 785
  • 3
  • 16

Code to generate graph in Matlab - review for best practice or speedup.

I use this matlab code...

load ~/emailAnalysis/results.txt
results=results(size(results,1)-400:size(results,1),:)
temp = results(:,3)-1238370000;
h=plot(temp,smooth(results(:,1)),':b')
set(h,'LineWidth',1)
ylim([0 80])
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XGrid','on')
ylabel('Emails')
hold on
i=plot(temp,smooth(results(:,4)),'r')
j=plot(temp,smooth(results(:,5)),'-g')
k=plot(temp,smooth(results(:,6)),'m')
xlim([max(temp)-(86400*7),max(temp)-1])
set(gca,'XTick',[1:86400:(86400*max(temp))+1])
set(gca,'XTickLabel',['Mon';'Tue';'Wed';'Thu';'Fri';'Sat';'Sun'])
set(j,'LineWidth',2)
set(h,'LineWidth',1)
set(i,'LineWidth',2)
set(k,'LineWidth',2)
xlabel('Time')
title('Size of inbox over time (seven days)')
print -r3000 -djpeg /XXXX/inbox7day.jpeg
hold off

To generate this graph http://www.cs.rhul.ac.uk/home/joseph/productivityFiles/inbox7day.jpeg, from data like

34 2012年01月21日 1327152611 5 16 10
32 2012年01月21日 1327154411 5 14 9
32 2012年01月21日 1327156209 5 14 9
34 2012年01月21日 1327158012 5 14 9
34 2012年01月21日 1327159808 5 15 9
34 2012年01月21日 1327161611 5 15 9
34 2012年01月21日 1327163406 5 15 9
33 2012年01月21日 1327165211 5 13 9
34 2012年01月21日 1327167011 5 13 9
31 2012年01月21日 1327168810 4 12 8

but it's a little slow, and also probably not very elegant (it's my first use of matlab) I'm interested in any tips for best practice, tips for speeding it up, or examples of how I might do the same things in R....

default

AltStyle によって変換されたページ (->オリジナル) /