90 likes | 189 Views
More bits and pieces. No over arching theme; just stuff that is useful. how to print a figure to a file fprintf handle graphics Read chapter 9 for next class!. But first, where are we going? How do we answer
E N D
More bits and pieces No over arching theme; just stuff that is useful. how to print a figure to a file fprintf handle graphics Read chapter 9 for next class!
But first, where are we going? • How do we answer • Is the globe warming? So why has it not warmed significantly in the last 10 years? • How can you estimate how fast the globe is warming from data? How fast CO2 is increasing? • How can we show that, for example, winds control coastal ocean temperature, or nutrient levels in soil are related to rainfall rates. • Why is your error estimate in the homework wrong? and how can we make it right?
You have a figure; how to save it to a file? • Why not just use the gui? • print • print %straight to printer • print mypicture.ps • print -dpng -r200 mypicture.png • What format should you use?
how to change properties of something you plot (like the lines in this example)? • handle graphics • plot(x,y,’linewidth’,2) • How do you find the properties? • “doc plot” • The results of doc have many examples, and are much more complete than the “help” pages. They are the manuals online. • see next page
How do you print numbers properly? Imagine you have xmean, and want to print just the significant digits: >> xmean xmean = 1.7725 >> • Well, that is not helpful.
Use fprintf! • Horrible syntax left over from C! >> fprintf('The value of xmean is %4.2f, and xmean^2 is %4.2f\n',xmean,xmean^2) The value of xmean is 1.77, and xmean^2 is 3.14 >> • explain text • explain %4.2f notation • and %4.2e • explain \n
What happens if you don’t include enough %f’s to print an array? >> fprintf(’a big number %5.2f\n',big_huge_array)
On debugging! %Making a histogram and repeating above with 15 sets of random #'s subplot(2,1,2) x=rand([20000,15]); hist(x,-8:0.1:8); xlabel('x') ylabel('# of points') title('bin size 0.1, sum of 15 sets') hold on s1=sum(x,1); mean1=mean(s1); std1=std(s1); max1=mean1+std1; min1=mean1-std1; index1=find((x>=min1)&(x<=max1)); length(index1)/20000