# box_vals.m - What does the function do?

*(You don't need to enter the commands below. They are already included in the code* `box_vals.m`*. This document is only for you to learn what's inside the blackbox.)*

## Contents

## Box-selecting

The function ** box_cursor** allows you to select the region of the image in which you want to carry out the calculation, and save the location of the
box in

**and the box size in**

`(x0,y0)`**.**

`(nx,ny)`[x0,y0,nx,ny] = box_cursor;

## Box-defining

The function ** box_vals.m** takes two input,

**as the cleaned intensity map, and**

`av`**as the variance map. Now, recall that the colon operator (**

`difs`**) returns a range of subscripts defined by the numbers before and after it. Therefore**

`:`**gives the values from subscript**

`x:(x+nx)`**to subscript**

`x`**. The following commands:**

`x+nx`avbox = av(y0:(y0+ny), x0:(x0+nx)); difbox = difs(y0:(y0+ny), x0:(x0+nx));

generate a box ** avbox** as a subarray of data array

**, and a box**

`av`**as a subarray of data array**

`difbox`**.**

`difs`## Calculating mean values and standard deviations

After we construct the two boxes we want to analyze, we can apply those MATLAB commands for numerical arrays on them. The
mean value of each box can be calculated by using the MATLAB internal function ** mean**:

avm = mean(avbox(:)); dfm = mean(difbox(:));

Similarly, the MATLAB function ** std** is applied here to calculate the standard deviations:

sigav = std(avbox(:)); sigdif = std(difbox(:));

## Printing results

The last two commands are just to print out those values evaluated in this function.

fprintf(1,'mean intensity = %0.3f, std of intensity = %0.3f\n', avm, sigav); fprintf(1,'mean variance = %0.3f, std of variance = %0.3f\n', dfm, sigdif);