How can I squeeze a variable to have the same size or dimension?

5 visualizaciones (últimos 30 días)
Larissa Britz
Larissa Britz el 18 de Oct. de 2018
Comentada: Walter Roberson el 18 de Oct. de 2018
Hi, I'm new to matlab, and have this tiny problem, and I hope you can help me as fast as yours amazing brains can solve, because I have to resolve this for a test tomorrow. So, I know it is really basic, but I just can't get it right.
I have to get a map with pcolor with lat, lon, and wind (and later, time, but babysteps first):
>> pcolor(lat1, lon1, wind)
ERROR using pcolor (line 59)
Matrix dimensions must agree.
>> size lat1
ans =
1 4
>> size wind
ans =
1 4
They have the same dimensions, why can't it recognize?
Also, I've squeezed Wind before >> size wind (from 721x51x61 to 51x61) to have the same size as lat/lon.
Can someone help me, please?!
  2 comentarios
Larissa Britz
Larissa Britz el 18 de Oct. de 2018
So guys! I've got it (not quite, but a map just emerged in my screen, and it is beautiful) I wrote:
>> pcolor(lat1, lon1, squeeze(swhgt(1,:,:))')
So, I know that squeeze(swhgt(1,:,:) takes off one dimension, I think. But, I have to use ' to work, why? I was just working with some notes from my class and this was right for some reason, can someone explain?
*swght is wind with all dimensions
Walter Roberson
Walter Roberson el 18 de Oct. de 2018
You might have needed the .' because in MATLAB, the first dimension of an array for pcolor is the vertical dimension (y) and the second dimension is the horizontal dimension (x)

Iniciar sesión para comentar.

Respuestas (1)

madhan ravi
madhan ravi el 18 de Oct. de 2018

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by