# MATLAB Tutorial 3

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## Using FVG Curtain

This example demonstrates a way to quickly visualise depth profile results at a single timestep along a line in the xy plane. The goal is to plot an fvg_sheet on a top axis, while visualise the 3D nature of data along a line through the center. While mostly used for visualising 3D results, this can be used with 2D data, to get an idea of the bathymetry, or (with a lot more work) to visualise against some 3D data.

## Basic Setup

An fvgraphics object must first be created with two axes, and an fvg_sheet object in the top axis. For this tutorial, we will be interested in visualising salinity.

```fobj = fvgraphics;
ax = myaxes(gcf,2,1);     %BMTWBM function for custom axes, or you can use the MATLAB builtin 'subplot'
mycolor(ax(1),[0 40 20]); %BMTWBM function for custom colorbar, or you can use the MATLAB builtin 'colorbar'
mycolor(ax(2),[0 40 20]);

modfil = 'C:\users\COM\TUFLOWFV\results\example_model_output.nc';

sheetObj = fvg_sheet(fobj,modfil,'peerObj',ax(1),'Variables','SAL');
```

### Specifying Curtains

We can now use fvg_curtain to create the curtain object. This requires a few more inputs than fvg_sheet or fvg_sheetvec. In order to calculate the cells that our curtain object needs to extract, we need to give it the geo file that TUFLOWFV automatically outputs, it should be wherever the log files have been stored for your run. We also need to give it some points as a pline, to specify the line to create the curtain under. These points are a vector of xy coordinates. This is useful when you know the curtain that you wish to see, and want to be able to reproduce it.

```geofil = 'C:\users\COM\TUFLOWFV\input\log\example_model_output_geo.nc';

pline = [365128, 81286355 ; 365100, 81286300]; %  [ x1,y1 ; x2,y2 ]

curtObj = fvg_curtain(fobj,modfil,geofil,pline,'Variables','SAL');
```

This creates the curtain that we want and allows us to scroll through time. There is no limit to the number of points in a pline, allowing users to create long lines that wrap around lots of turns. You will probably notice that nothing can be seen properly. MATLAB views objects in the xy plane by default, to change your viewing position, you can either click the rotate tool at the top of the figure, or use the view command in MATLAB. MATLAB plots also do not know units. If you are in spherical coordinates, x and y axes are probably in degrees, and you are trying to make your z axis in meters. If you are in Cartesian coordinates, your line may be a lot longer (1000s of meters?) than your depth (10s of meters?). To ensure that you can scale these to look appropriate, use the dataaspectratio property of axes.

```set(ax(2),'dataaspectratio',[1 1 0.1]);

view(ax(2),3)
```

### Pline options

The pline specification is useful when you know the line that you want to extract on, and want it to be reproducible. For cases when you may just want to see a curtain in an approximate area and don't want to have to calculate some pline points, you have the option of being able to draw the line on your fvg_sheet (if there's one there). All you have to do is set the pline to be empty.

```% start again
fobj = fvgraphics;
ax = myaxes(gcf,2,1);     %BMTWBM function for custom axes, or you can use the MATLAB builtin 'subplot'
mycolor(ax(1),[0 40 20]); %BMTWBM function for custom colorbar, or you can use the MATLAB builtin 'colorbar'
mycolor(ax(2),[0 40 20]);

modfil = 'C:\users\COM\TUFLOWFV\results\example_model_output.nc';

sheetObj = fvg_sheet(fobj,modfil,'peerObj',ax(1),'Variables','SAL');

geofil = 'C:\users\COM\TUFLOWFV\input\log\example_model_output_geo.nc';

curtObj = fvg_curtain(fobj,modfil,geofil,[],'Variables','SAL','peerObj',ax(2));
```

You will notice this will return the comment 'left click to define myline, right click to end it'. Do as it says, click as many points as you like with left click, but for the last point use a right click. After a second or two, your curtain will appear. This can be done with multiple curtains to plot them all at once.

## Curtain Specific Options

Curtain visualisations have several options that differ from the other objects. The chainage property allows the user to visualise the curtain in 2D, as if projected onto an x,z plane. To plot depth against the pline

```set(fvg_curtain,'Chainage',true);
```

You will have noticed that the isometric view is now inappropriate. To adjust the view into the x z plane do the following

```view(ax(2),1,0)
```