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

5 views (last 30 days)
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 Comments
Larissa Britz
Larissa Britz on 18 Oct 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 on 18 Oct 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)

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 18 Oct 2018

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!