Reputation: 89
I have a matrix defined like so: height(:,:,:,:). The four dimensions are "Latitude, Longitude, Altitude, and Time". Specifically here, I'm trying to make this 4D variable be able to display an actual height in meters rather than the current form of expression which is the total height of the called atmospheric layer (including the ones below it). For every latitude, longitude, and time combination the height is different, there is no standard "layer height".
When the variable for height is called, it displays the "top" height of the grid cell specified, but they're additive. For instance, if grid cell 1 is 40m in height and grid cell 2 was 42 meters in height calling grid cell 2 would give you a value of 82m. I want to change this so that the stored value is the
I've tried to create a for loop that, for each point, calls the layer height and subtracts the height of the layer before it to only give the height of the layer called. Like so:
h=0;
for index = 2:27
for space = 1:26
h = h + flheight(:,:,index,:) - flheight(:,:,space,:)
end
end
Currently I'm receiving the wrong value of magnitude " 4.2961e+05" though... but its probably obvious to everyone but myself why that is.
The sort of value I'm expecting when I call the number is roughly "32" meters instead.
Also, it looks like my matrix only has one height dimension (dimension 3) instead of the expected 27 (which probably has something to do with the massive size of my output).
After doing this I plan to manually add in the height of the top layer to the matrix created somehow, but that's another step. For now I'm trying to get the individual height of the layers 2->27.
So: This is the format of an example data snippit from flheight. In actuality the length of each dimension is flheight(336,264,27,25) but for this example I'm gonna make a condensed version.
flheight(1,1,:,1) would be roughly:
[ 40
82
124
169]
Basically, there are 27 altitudes for each latitude, longitude and time combination. Instead of displaying the total height I would like it to displace to difference in height (as stated via comment!). I'm trying to make it so that variable "h" would translate to the following:
[ 40
42
42
45 ]
Also, for each height and time combination there is a 336x264 matrix.
Upvotes: 0
Views: 39
Reputation: 89
So, I solved it... at least mostly!
My end code was:
for index = 2:27
h(:,:,index,:) = flheight(:,:,index,:) - flheight(:,:,index-1,:);
end
My problem was that I was only saying:
h= ...
but instead I needed to be saying:
h(:,:,index,:) = ...
so that I was actually changing indices within the altitude dimension!
Upvotes: 0