Mount St. Helens is an active stratovolcano in Washington state. Its May 1980 eruption was the deadliest and most costly volcanic event in United States history. Here, you will examine changes in DEMs...

Mount St. Helens is an active stratovolcano in Washington state. Its May 1980 eruption was the deadliest and most costly volcanic event in United States history. Here, you will examine changes in DEMs recorded before and after the eruption.

Hints

Find detailed instructions throughout the code. You can copy the starter code from MATLAB Grader (see below) into your own script to get started. It contains a lot of comments (instructions), and a number of blank lines for you to write your own code in. Copy all of the starter code into your own script, and do your work there. Save frequently. Then, you can periodically paste your work back into MATLAB Grader and get feedback.Find hints and general instructions on the MATLAB Grader page for "Lab 1: Statistical moments, histograms, and data distributions". You probably came here from that page.You'll need to obtain the data file from UBlearns >> Lab Code Resources >> Lab materials (data files) >> Lab 1. Save this in the folder you're working in on your own computer. (I have already supplied this data to MATLAB Grader; you don't need to do that.)


% Always start your work by clearing your workspace of all variables: clear variables % However, if you do this in the MATLAB web environment, it will not grade any of your work!! % % ARE YOU WORKING ON YOUR OWN DESKTOP COPY OF MATLAB? % YES -> Start your code with % clear variables % < uncomment="" this="" line="" %="" no,="" i="" am="" pasting="" this="" into="" matlab="" grader="" %="" -=""> Do NOT clear variables. % % % Two DEMs are contained in the MATLAB workspace file 'StHelensDEMs.mat'. These give % elevation data, in meters, at particular x,y points. % There is also information about the x,y grid location of each point, in UTM Zone 10N. % Load that file and see these variables appear in your workspace. % Use the function named load. % Type "doc load" (omit the quotes) in the command window to get help on the syntax and see examples. load StHelensDEMs.mat % Have a look at the "old" (pre-1980) and "new" (2002) topography. % They are in variables named % DEM0 ("old" DEM) % DEM1 ("new" DEM) % Use the following functions to visualize the data: % surf % colorbar % title % This will let you plot your data in 3D, supply a visual key to the colors, and give % your plot a meaningful title. % Read the help files for these functions. Start with surf. Type "doc surf" (no quotes) in the command window. % % Note: The data are on a relatively dense grid (30 x 30 meters). With a grid this dense, % black the grid lines can totally black out the plot and make your data invisible! % To counter this, you can use the argument 'LineStyle','None' in your surf command: % surf(MYx,MYy,MYzDATA,'LineStyle','None') % Try it yourself: % Plot the data using surf % Add a colorbar using colorbar % Add a title using title figure(1); clf; % < uncomment="" this="" line="" and="" start="" working="" on="" your="" "old="" dem"="" figure="" in="" the="" following="" blank="" lines.="" surf(dem0,'linestyle','none')="" colorbar="" title("old="" st.helens="" topography")="" figure(2);="" clf;="" %="">< uncomment="" this="" line="" and="" start="" working="" on="" your="" "new="" dem"="" figure="" in="" the="" following="" blank="" lines.="" surf(dem1,'linestyle','none')="" colorbar="" title("new="" st.helens="" topography")="" %="" notice="" the="" "rotate="" 3d"="" tool="" in="" the="" figure="" toolbar.="" you="" can="" select="" this="" tool="" and="" rotate="" %="" the="" plot="" around="" with="" your="" mouse="" to="" get="" a="" 3d="" view="" of="" the="" data.="" %="" %="" for="" a="" clear="" comparison,="" you="" can="" plot="" both="" datasets="" into="" the="" same="" figure="" using="" the="" subplot="" command.="" %="" read="" the="" help="" file="" for="" subplot="" to="" learn="" its="" syntax.="" %="" type="" "doc="" subplot"="" in="" the="" command="" window="" to="" get="" the="" help="" file="" for="" subplot="" and="" see="" examples.="" %="" %="" then,="" display="" the="" dems="" side="" by="" side="" in="" the="" same="" figure="" using="" subplot="" and="" surf="" as="" before.="" figure(3);="" clf;="" %="">< uncomment this line and start working on your figure in the following blank lines. subplot(1, 2, 1); surf(demx, demy, dem0,'linestyle','none') colorbar title("old st.helens topography") subplot(1, 2, 2); surf(demx, demy, dem1,'linestyle','none') colorbar title("new st.helens topography") % for accurate presentation of geological data, you should also display the % x,y locations of the data. these are contained in the variables % demx % demy % in your workspace, and the units for these data are meters. % the function surf can accept x,y location data as inputs, in addition to z data. % read the help file for surf to learn how to include x,y location data in surf plots. % then, redo your side-by-side dem plots with location data added. % you may notice that the presentation aspect of the mountain is a bit different % between figures 3 and 4. how is it different? which display is "better"? % (use google maps or some other outside mapping tool to compare.) % % note: you can have some fun changing the colors that the data display in. read the help file % for the matlab function colormap to learn more. % % finally, let's save this plot as a jpeg file for use in applications outside matlab. the syntax is % print('filename.jpeg','-djpeg') % where the first argument is what you'd like to call the file, and the second is a flag that tells % matlab the image format you'd like (in this example, jpeg). % you can read the help file for the matlab function print to see its other options. % % *** important notice: *** % any figure that appears in your lab report should be generated using the matlab function print. % do not take a screenshot of your plot and paste it in your lab report. that looks unprofessional. % *** *** *** *** *** *** *** print('sthelensdem.jpeg', '-djpeg') %% part 2. basic analysis of dem data % now that you have imported, viewed, and exported a plot of the dem data, let's begin to analyze the data. % we will begin with simple commands that are built into matlab: addition/subtraction, max, min, and mean. % % use the max function to determine the maximum height of the mountain, before and after eruption. % name these variables % summit0 % summit1 % remember the 'all' flag, which considers all elements of a 2d dataset, instead of each column separately. summit0 = max(dem0); summit1 = max(dem1); % what is the change in elevation of the mount st. helens summit before and after eruption, as it would appear in a % gazetteer of heights of mountain peaks? % name this variable % summitchange % this gives us a general idea of the elevation change, but it is incomplete. the new summit of % mount st. helens is on the crater rim, whereas the old summit was more or less centered on the area % that is currently the crater. the greatest elevation change thus occurs near the center of the % crater. we can calculate this change by first calculating a map of the elevation change at every % pixel, and then applying the min function to this dataset (remember the 'all' flag). % name your variables % demchange % maxdecrease % what was the mean change in our map area? create a new variable meanchange and use the function mean % to calculate this. remember the 'all' flag. % meanchange % you can see that the mean change was quite small compared to the maximum change. this is in part because we % averaged over the entire mountain area. instead, let's calculate the mean change in the region near the summit % / crater only. % we can identify the near-summit area using indices of the dem matrices. % for now, let's use % row numbers 160 through 220 and % column numbers 130 through 200. % make new variables called % crater0 % crater1 % craterchange % based on these indices. % remember that a colon can create vectors of consecutive numbers, % e.g. 1:4 creates a vector [1 2 3 4]; % what are the mean elevations near the crater area before and after eruption, and what was the mean change? % name these variables % meancrater0 % meancrater1 % meancraterchange %% part 3. hyposmetry of mount st. helens % a useful way to analyze topography within a region is through hypsometry, or the graphical study of the % distribution of elevations. we will make histograms of mount st. helens before and after the eruption and use % these as a basis for further analysis. % read the help file for the matlab function histogram. % using the original elevation datasets for the entire mountain, % dem0 % dem1 % make two histograms, one for the elevation distribution of each dem. plot them in % the same figure, on top of each other, for ease of comparison. % use bins that range from 0 m to 3000 m and have a bin width of 30 m. % to start this, make a new variable for your bin and call it % binvec % % tips: % you can use the command "hold on" to freeze the plot and allow it to accept % a second (or third or fourth...) set of data to be plotted on top of it. % hold('on') % or % hold on % both sytaxes are equivalent and do the same thing. % read the help file for the matlab function hold for more details. % % remember to use the commands xlabel and ylabel to give your graph meaningful % axes labels, and use title to give it a meaningful title. read these help files % for more instructions. % % you should also use legend to create a key that labels each curve. read the % help file, as always, for more information. % the way you present the data can affect your interpretation of the data. you can and should try making these histograms with different % bin widths, number of bins, etc. sometimes this can change features in the plots. trying many bin sizes will allow you to make sure you % have a feel for what information the data truly contain, versus what information any spurious bin size might suggest. % you might also try making histograms of demchange, craterold, craternew, and craterchange. % you can use these histograms to help you interpret the data in a few contexts: % what are the mean, standard deviation, and skewness of the elevation dataset, and how did these change as a result of the eruption? % at which elevations did the mountain gain and lose mass as a result of the eruption? % which elevations were least affected by the eruption? % what volume of earth material did the mountain lose as a result of the eruption? % the histogram function comes with a few options. changing those options allows us to make histograms, where the y axis shows the number of % counts for each bin, or relative probability charts, where the y axis shows the count per bin divided by the total number of observations, % or probability density functions (pdfs), where the y uncomment="" this="" line="" and="" start="" working="" on="" your="" figure="" in="" the="" following="" blank="" lines.="" subplot(1,="" 2,="" 1);="" surf(demx,="" demy,="" dem0,'linestyle','none')="" colorbar="" title("old="" st.helens="" topography")="" subplot(1,="" 2,="" 2);="" surf(demx,="" demy,="" dem1,'linestyle','none')="" colorbar="" title("new="" st.helens="" topography")="" %="" for="" accurate="" presentation="" of="" geological="" data,="" you="" should="" also="" display="" the="" %="" x,y="" locations="" of="" the="" data.="" these="" are="" contained="" in="" the="" variables="" %="" demx="" %="" demy="" %="" in="" your="" workspace,="" and="" the="" units="" for="" these="" data="" are="" meters.="" %="" the="" function="" surf="" can="" accept="" x,y="" location="" data="" as="" inputs,="" in="" addition="" to="" z="" data.="" %="" read="" the="" help="" file="" for="" surf="" to="" learn="" how="" to="" include="" x,y="" location="" data="" in="" surf="" plots.="" %="" then,="" redo="" your="" side-by-side="" dem="" plots="" with="" location="" data="" added.="" %="" you="" may="" notice="" that="" the="" presentation="" aspect="" of="" the="" mountain="" is="" a="" bit="" different="" %="" between="" figures="" 3="" and="" 4.="" how="" is="" it="" different?="" which="" display="" is="" "better"?="" %="" (use="" google="" maps="" or="" some="" other="" outside="" mapping="" tool="" to="" compare.)="" %="" %="" note:="" you="" can="" have="" some="" fun="" changing="" the="" colors="" that="" the="" data="" display="" in.="" read="" the="" help="" file="" %="" for="" the="" matlab="" function="" colormap="" to="" learn="" more.="" %="" %="" finally,="" let's="" save="" this="" plot="" as="" a="" jpeg="" file="" for="" use="" in="" applications="" outside="" matlab.="" the="" syntax="" is="" %="" print('filename.jpeg','-djpeg')="" %="" where="" the="" first="" argument="" is="" what="" you'd="" like="" to="" call="" the="" file,="" and="" the="" second="" is="" a="" flag="" that="" tells="" %="" matlab="" the="" image="" format="" you'd="" like="" (in="" this="" example,="" jpeg).="" %="" you="" can="" read="" the="" help="" file="" for="" the="" matlab="" function="" print="" to="" see="" its="" other="" options.="" %="" %="" ***="" important="" notice:="" ***="" %="" any="" figure="" that="" appears="" in="" your="" lab="" report="" should="" be="" generated="" using="" the="" matlab="" function="" print.="" %="" do="" not="" take="" a="" screenshot="" of="" your="" plot="" and="" paste="" it="" in="" your="" lab="" report.="" that="" looks="" unprofessional.="" %="" ***="" ***="" ***="" ***="" ***="" ***="" ***="" print('sthelensdem.jpeg',="" '-djpeg')="" %%="" part="" 2.="" basic="" analysis="" of="" dem="" data="" %="" now="" that="" you="" have="" imported,="" viewed,="" and="" exported="" a="" plot="" of="" the="" dem="" data,="" let's="" begin="" to="" analyze="" the="" data.="" %="" we="" will="" begin="" with="" simple="" commands="" that="" are="" built="" into="" matlab:="" addition/subtraction,="" max,="" min,="" and="" mean.="" %="" %="" use="" the="" max="" function="" to="" determine="" the="" maximum="" height="" of="" the="" mountain,="" before="" and="" after="" eruption.="" %="" name="" these="" variables="" %="" summit0="" %="" summit1="" %="" remember="" the="" 'all'="" flag,="" which="" considers="" all="" elements="" of="" a="" 2d="" dataset,="" instead="" of="" each="" column="" separately.="" summit0="max(DEM0);" summit1="max(DEM1);" %="" what="" is="" the="" change="" in="" elevation="" of="" the="" mount="" st.="" helens="" summit="" before="" and="" after="" eruption,="" as="" it="" would="" appear="" in="" a="" %="" gazetteer="" of="" heights="" of="" mountain="" peaks?="" %="" name="" this="" variable="" %="" summitchange="" %="" this="" gives="" us="" a="" general="" idea="" of="" the="" elevation="" change,="" but="" it="" is="" incomplete.="" the="" new="" summit="" of="" %="" mount="" st.="" helens="" is="" on="" the="" crater="" rim,="" whereas="" the="" old="" summit="" was="" more="" or="" less="" centered="" on="" the="" area="" %="" that="" is="" currently="" the="" crater.="" the="" greatest="" elevation="" change="" thus="" occurs="" near="" the="" center="" of="" the="" %="" crater.="" we="" can="" calculate="" this="" change="" by="" first="" calculating="" a="" map="" of="" the="" elevation="" change="" at="" every="" %="" pixel,="" and="" then="" applying="" the="" min="" function="" to="" this="" dataset="" (remember="" the="" 'all'="" flag).="" %="" name="" your="" variables="" %="" demchange="" %="" maxdecrease="" %="" what="" was="" the="" mean="" change="" in="" our="" map="" area?="" create="" a="" new="" variable="" meanchange="" and="" use="" the="" function="" mean="" %="" to="" calculate="" this.="" remember="" the="" 'all'="" flag.="" %="" meanchange="" %="" you="" can="" see="" that="" the="" mean="" change="" was="" quite="" small="" compared="" to="" the="" maximum="" change.="" this="" is="" in="" part="" because="" we="" %="" averaged="" over="" the="" entire="" mountain="" area.="" instead,="" let's="" calculate="" the="" mean="" change="" in="" the="" region="" near="" the="" summit="" %="" crater="" only.="" %="" we="" can="" identify="" the="" near-summit="" area="" using="" indices="" of="" the="" dem="" matrices.="" %="" for="" now,="" let's="" use="" %="" row="" numbers="" 160="" through="" 220="" and="" %="" column="" numbers="" 130="" through="" 200.="" %="" make="" new="" variables="" called="" %="" crater0="" %="" crater1="" %="" craterchange="" %="" based="" on="" these="" indices.="" %="" remember="" that="" a="" colon="" can="" create="" vectors="" of="" consecutive="" numbers,="" %="" e.g.="" 1:4="" creates="" a="" vector="" [1="" 2="" 3="" 4];="" %="" what="" are="" the="" mean="" elevations="" near="" the="" crater="" area="" before="" and="" after="" eruption,="" and="" what="" was="" the="" mean="" change?="" %="" name="" these="" variables="" %="" meancrater0="" %="" meancrater1="" %="" meancraterchange="" %%="" part="" 3.="" hyposmetry="" of="" mount="" st.="" helens="" %="" a="" useful="" way="" to="" analyze="" topography="" within="" a="" region="" is="" through="" hypsometry,="" or="" the="" graphical="" study="" of="" the="" %="" distribution="" of="" elevations.="" we="" will="" make="" histograms="" of="" mount="" st.="" helens="" before="" and="" after="" the="" eruption="" and="" use="" %="" these="" as="" a="" basis="" for="" further="" analysis.="" %="" read="" the="" help="" file="" for="" the="" matlab="" function="" histogram.="" %="" using="" the="" original="" elevation="" datasets="" for="" the="" entire="" mountain,="" %="" dem0="" %="" dem1="" %="" make="" two="" histograms,="" one="" for="" the="" elevation="" distribution="" of="" each="" dem.="" plot="" them="" in="" %="" the="" same="" figure,="" on="" top="" of="" each="" other,="" for="" ease="" of="" comparison.="" %="" use="" bins="" that="" range="" from="" 0="" m="" to="" 3000="" m="" and="" have="" a="" bin="" width="" of="" 30="" m.="" %="" to="" start="" this,="" make="" a="" new="" variable="" for="" your="" bin="" and="" call="" it="" %="" binvec="" %="" %="" tips:="" %="" you="" can="" use="" the="" command="" "hold="" on"="" to="" freeze="" the="" plot="" and="" allow="" it="" to="" accept="" %="" a="" second="" (or="" third="" or="" fourth...)="" set="" of="" data="" to="" be="" plotted="" on="" top="" of="" it.="" %="" hold('on')="" %="" or="" %="" hold="" on="" %="" both="" sytaxes="" are="" equivalent="" and="" do="" the="" same="" thing.="" %="" read="" the="" help="" file="" for="" the="" matlab="" function="" hold="" for="" more="" details.="" %="" %="" remember="" to="" use="" the="" commands="" xlabel="" and="" ylabel="" to="" give="" your="" graph="" meaningful="" %="" axes="" labels,="" and="" use="" title="" to="" give="" it="" a="" meaningful="" title.="" read="" these="" help="" files="" %="" for="" more="" instructions.="" %="" %="" you="" should="" also="" use="" legend="" to="" create="" a="" key="" that="" labels="" each="" curve.="" read="" the="" %="" help="" file,="" as="" always,="" for="" more="" information.="" %="" the="" way="" you="" present="" the="" data="" can="" affect="" your="" interpretation="" of="" the="" data.="" you="" can="" and="" should="" try="" making="" these="" histograms="" with="" different="" %="" bin="" widths,="" number="" of="" bins,="" etc.="" sometimes="" this="" can="" change="" features="" in="" the="" plots.="" trying="" many="" bin="" sizes="" will="" allow="" you="" to="" make="" sure="" you="" %="" have="" a="" feel="" for="" what="" information="" the="" data="" truly="" contain,="" versus="" what="" information="" any="" spurious="" bin="" size="" might="" suggest.="" %="" you="" might="" also="" try="" making="" histograms="" of="" demchange,="" craterold,="" craternew,="" and="" craterchange.="" %="" you="" can="" use="" these="" histograms="" to="" help="" you="" interpret="" the="" data="" in="" a="" few="" contexts:="" %="" what="" are="" the="" mean,="" standard="" deviation,="" and="" skewness="" of="" the="" elevation="" dataset,="" and="" how="" did="" these="" change="" as="" a="" result="" of="" the="" eruption?="" %="" at="" which="" elevations="" did="" the="" mountain="" gain="" and="" lose="" mass="" as="" a="" result="" of="" the="" eruption?="" %="" which="" elevations="" were="" least="" affected="" by="" the="" eruption?="" %="" what="" volume="" of="" earth="" material="" did="" the="" mountain="" lose="" as="" a="" result="" of="" the="" eruption?="" %="" the="" histogram="" function="" comes="" with="" a="" few="" options.="" changing="" those="" options="" allows="" us="" to="" make="" histograms,="" where="" the="" y="" axis="" shows="" the="" number="" of="" %="" counts="" for="" each="" bin,="" or="" relative="" probability="" charts,="" where="" the="" y="" axis="" shows="" the="" count="" per="" bin="" divided="" by="" the="" total="" number="" of="" observations,="" %="" or="" probability="" density="" functions="" (pdfs),="" where="" the="">
Sep 13, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here