Homework question on MATLAB Program This assignment will hel
Homework question on MATLAB Program
This assignment will help you understand how for loops can be used to accomplish tasks that would otherwise require extensive time and would stress Excel’s capabilities. Coding Constraints: You may not use reshape() to solve Part 1 or 2. You must use FOR LOOPs. However, you may use embedded MATLAB syntax to check your answer. PART 1. Reorganize weather station measurements into column format The readings from a weather station in Los Angeles outputs average daily measurements of atmospheric variables. The weather station file WS_2010.txt includes the year, month, day, Temperature [K], Relative Humidity [%], and Surface pressure [Pa], in that order, in one single row. There are 365 days of observation. For example: 2010 1 1 286.90 62.88 101768.180 2010 1 2 286.64 61.62 101746.805 2010 1 3 286.38 61.05 101754.727 2010 1 4 286.41 63.31 101779.648 2010 1 5 286.67 … The numbers above in bold/ are the date values followed by the atmospheric readings. • Use FOR LOOP(S) syntax to separate the daily values into a six column matrix. • There are several ways to perform this analysis. • Save this matrix to a file called “LA_climate_2010_columns.txt”
PART 2. Inspired by 3D research project using hydrologic simulation In this part you are using a simulated saturation field. Soil saturation is a measurement of the water content in the soil pore space. Saturation ranges from 0 (no water in pore space) to 1 (100% water in pore space). Figure 1 has the distributed saturation field for a small study area located in Aurora, Colorado. The file (urb.out.satur.peak.txt) was generated from a hydrologic simulation program called ParFlow. The outputs are generated as a single column vector with a three value header. The header indicates the number of rows, number of columns, and number of layers in the domain, respectively. In this file there are 154 rows, 165 columns, and 2 layers in the subsurface. In order to visualize the simulation, the single-dimension output must be reshaped into a three-dimensional field using a very specific pattern. If you improperly reshape the file, the image will appear pixelated and random. Create an output variable, sat_out, following these specific guidelines: • Create a 3D “dummy” matrix, sat_out with 154 rows, 165 columns, and 2 layers in the subsurface. • Watch the instructional video Hwk3_Part2_explanation.mp4 to follow the steps required to properly format sat_out (Optional) To visualize (and check) your satout variable, copy/paste the following syntax into your script: imagesc(satout(:,:,1)) % visualize only the top layer colormap(jet) colorbar
Solution
Here is a simple, clean way to re organize the data
