Sunday, October 26, 2014

Writing text output of a table

    % open file, write out header
    % write out transpose of table4, with six total places per column, two decimal places (or none for npts)

    fileID = fopen('table4.txt','w');
    fprintf(fileID,'%6s %6s %6s %6s %6s %6s \n',
            'a', 'b1', 'b2', 'R^2', 
            'rmse', 'npts');
    fprintf(fileID,'%6.2f %6.2f %6.2f %6.2f 
            %6.2f %6.0f \n',table4');
    fclose(fileID);

Monday, July 28, 2014

extracting odd-shaped parts of figures

I have some photos of instruments, but there is a lot of stuff in the background cluttering up the photo. I want to crop out the instruments and arrange them in a single figure.


  1. Import the figure at high resolution into photoshop
  2. In the layer dialog drag the layer down to the bottom (the icon for creating a new later) to create a copy of the layer.
  3. Make a layer in the middle of the two layers and Fill it with white in the background - when you crop out the image, you want a white background, but if the original image is in the background you won't get that.)
  4. Use the Lasso tool, "L" to outline the shape you want to keep. You can click "enter" to complete the polygon.
  5. cmd-shift-I to invert to select the area around the shape.
  6. Delete to remove the area around the shape.
  7. Save as a jpg.


vs.

photos from M. Tivey




Monday, May 19, 2014

mac vs. pc matlab continued

Might have more posts here soon since I just agreed to be a guinea pig for a software documentation project and they already picked apart my first very simple script for not being componentized, not cross platform, and has lots of runtime dependencies.

From stack overflow. Actual functions to make code cross-platform.

Of course, if you try to access a Windows-style path on a Mac, it will error.
MATLAB includes a set of functions that make it fairly easy to make your code cross-platform with respect to these sorts of issues. Take a look at, for example, the functions fullfilefilepartsfileseppathsepispc, and ismac.

Tuesday, February 4, 2014

crop in illustrator

From klf:
Something for mat-illustrator-labor wot I just learned here (http://forums.adobe.com/thread/319423):

You know how you can crop things really easily in Photoshop but not in Illustrator?  This is a huge pain for figures with a lot of white space that you want to get rid of before submitting the figures for publication (e.g., for Matlab figures imported into Illustrator).  Here's a workaround in Illustrator that'll let you do what cropping does.

1. Open your big figure.  This figure includes some stuff you want to keep (e.g., data) and some stuff you want to get rid of (e.g., white space).
2. Create a shape on top of the figure the size and shape of the area you'd like to crop.  E.g., a rectangle.  Place it right over the stuff you want to keep.
3. Color that rectangle some color (e.g., white).  Doesn't matter what color.  Just make it something you can see.
4. Use the transparency palette to set the opacity of the rectangle to 0%.
5. Select the rectangle and the underlying figure.
6. Click on Object > Flatten transparency.  (Use 100% vector on the quality slider, and make sure the "Preserve alpha channel" box is unchecked.)
7. Ungroup the result.
8. Click on the things outside the rectangle and delete them.  Done!

Tuesday, January 7, 2014

compress a PDF online

http://compress.smallpdf.com/

Just compressed a 21 MB to 2 MB. Original pptx was 6 MB. Random.