Azzera filtri
Azzera filtri

Trying to make a pcolor plot of a frequency table. Matrix dimensions don't agree!

2 visualizzazioni (ultimi 30 giorni)
I have created a frequency table in matlab, with wave heights across the top and their direction down the side. The table has been created by sorting the data into intervals.
For example, the first column of the table contains waves between 0-1m high, the second column contains waves 1-2m, and so on and so forth up to 10m.
The first row contains waves with a direction of 0-30 degrees, the second row contains waves with a direction 30-60 degrees, and so on and so forth up to 360 degrees.
I am trying to do a pcolor plot of the frequency table but I am getting the matrix dimensions error. The thing is, I know why. I am using the pcolor(X,Y,C) command and whilst the frequency table contains 10 columns and 12 rows, my X and Y contain 1 more column and row respectively. This is because the data I am trying to plot lies between the interval boundaries so there will always be one more boundary than there are intervals.
Any tips on how to get around this? I feel like it should be a simple fix but alas :/
Thanks

Risposte (2)

Sean de Wolski
Sean de Wolski il 29 Mar 2013
Two options I see:
1) Remove the first or last row/column. It sounds like this isn't ideal for you.
2) Use interp1() to interpolate the midpoint between each set of values (this will give you matrices of size n-1). Then use these.

Pete
Pete il 29 Mar 2013
Thanks for your reply, after a bit of playing around, and since I'd prefer not to start interpolating, I found that imagesc(matrix) provides the plot I need, but the axis are labelled with each tick in the centre of each square. How do I edit the axis so that the numbers appear in line with the square edges? (Without the actual plot changing)

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by