Question regarding data grid

Hi I have a data set on a 0.5 grid, the dimension for x is 141, y is 71 and t is 38. I am trying to calculate the z score which I already did. I am trying to plot the the Z scores on a time series but since is greater than two dimensions is not possible to do it. Is there anyway to work around this without ruining the yearly data? Thanks in advance for your help

2 comentarios

darova
darova el 22 de Oct. de 2019
Attach some example and data
desert_scientist90
desert_scientist90 el 22 de Oct. de 2019
val(:,:,1) =
Columns 1 through 8
0.8697 -0.2439 -0.4631 -0.2680 -0.2385 0.1420 0.0102 -1.0239
Columns 9 through 16
-1.1259 -1.5321 -1.5886 -1.8558 -1.9435 -1.7930 -2.1038 -2.2191
Columns 17 through 24
-1.9535 -2.0331 -2.0710 -1.0314 -0.1241 0.3457 0.9845 1.2666
Columns 25 through 32
1.1053 1.0737 1.1622 1.5579 1.6004 2.2580 1.0220 0.6942

Respuestas (2)

Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019

0 votos

The uploaded file contains a single variable with size 1x71x38. If that is correct, just use the squeeze function to remove the singleton dimension.
Z = squeeze(Z);
The new size of Z is 71x38.
From here you can create a line plot for each column
plot(Z)
or a 3D surface
surf(Z)

5 comentarios

Hi Cris
It works!! I am trying to add the date on the graph by doing the following code
t = datetime(1980,2017)
plot(t(squeeze(z(1,71,:))));
but I am getting the following error
Error using datetime (line 601)
Numeric input data must be a matrix with three or six columns, or else three,
six, or seven separate numeric arrays. You can also create datetimes from a
single numeric array using the 'ConvertFrom' parameter.
Do you have any idea how to work around this?
Thanks for your help
Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019
I don't know what your dimensions mean, but you seem to suggest with your code that there are 38 years, and that that is what you want along the X-axis. I'd therefore do the following:
t = years(1980:2017)
plot(t,Z')
Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019
Editada: Cris LaPierre el 23 de Oct. de 2019
I'm not sure that's the way you want to visualize this data. Viewing that way makes it hard to see any patterns. Having each year be it's own line makes it easier to observe a yearly pattern related to the value of y.
plot(Z)
When plotting so X is year, it is connecting data points across years, masking any yearly trend (line 1 = first data point from each year, line 2 = second data point from each year, etc).
plot(t,Z')
desert_scientist90
desert_scientist90 el 23 de Oct. de 2019
Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019
Editada: Cris LaPierre el 23 de Oct. de 2019
I'm pretty sure this plot was created using the code
plot(Z(:))
Here, the values of X represent the index of the data point. The command Z(:) turns the entire array into a one-column vector. You can see that syntax described in this doc page. What that means is all the columns were placed head-to-tail. There are 71*38 data points, or 2698.
desert_scientist90
desert_scientist90 el 23 de Oct. de 2019

0 votos

I am trying to have one line for the 38 years which I got earlier but with the frequency which is 2698 instead of the years. When I was trying to do the plot the error message I was getting was that the vectors were not the same lenght. I am new to matlab i have spent hours trying to get this graph right. But I guess thats part of the process of learning to use something new.

2 comentarios

Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019
Yes, learning requires some practice. If you are brand new, have you gone through MATLAB Onramp? It might help introduce you in a guided, incremental way.
Cris LaPierre
Cris LaPierre el 23 de Oct. de 2019
I'm afraid I don't know enough about your data to tell you how you should combine the values to get a single line of data for all 38 years.

La pregunta está cerrada.

Preguntada:

el 22 de Oct. de 2019

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by