# How to plot contourf using following information?

4 visualizaciones (últimos 30 días)
UTKARSH VERMA el 7 de En. de 2021
Comentada: UTKARSH VERMA el 7 de En. de 2021
I am having data as follows:
lon 256*1double
lat 128*1double
time 3654*1double
pr 256*128*3654double
I am using contourf(lon,lat,pr(:,:,:)) or contourf(lon,lat,pr(:,:,:)') but there is error of dimension
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

KSSV el 7 de En. de 2021
pr is a 3D matrix, you cannot use contourf on a 3D matrix. You need to draw layer by layer.
[m,n,p] = size(pr) ;
for i = 1:p
contourf(lon,lat,pr(:,:,i)) ; % if throws error, trispose pr
drawnow
end
Also have a look on slice.
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
UTKARSH VERMA el 7 de En. de 2021
Thank you!

Iniciar sesión para comentar.

### Más respuestas (1)

Bjorn Gustavsson el 7 de En. de 2021
You would have to make one contour-plot for each time-step:
i_time = 1;
contourf(lon,lat,pr(:,:,i_time)')
If I understood the dimensions correctly. So to get all you'll have to "animate" in some fashion. What gives the best illustration of what's going on depends on what's going on (a tautology, I know) so you have to be prepared to try different ideas to see what works best. I can for example imagine something like this working:
for i_time = 1:(size(pr,3)-3)
contour(lon,lat,pr(:,:,i_time)',10,'b')
hold on
contour(lon,lat,pr(:,:,i_time+1)',10,'c')
contour(lon,lat,pr(:,:,i_time+2)',10,'g')
contour(lon,lat,pr(:,:,i_time+3)',10,'r')
hold off
drawnow
end
HTH
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
UTKARSH VERMA el 7 de En. de 2021
Thank you!

Iniciar sesión para comentar.

### Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

R2018a

### Community Treasure Hunt

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

Start Hunting!

Translated by