Further question about using pcolor
Afficher commentaires plus anciens
Dear MATLAB wizard,
I have read and used the answers that you gave to Alan B's question of a few days ago. I, too, am attempting to put concentrations on a map. I have uploaded my data from Excel, and split the latitude (LatDIC), longitude (LongDIC) and concentration (DIC) data into separate matrices that are one column of data each. I keep getting an error because pcolor does not seem to like that my data is not in a wide matrix.
figure(1); pcolor(LongDIC,LatDIC,DIC), shading flat, colorbar, title('DIC');
I have been trying to average the data using some code sent to me by someone else, but I am having problems because I don't know what their data set looked like to begin with. I have copied their code below.
% calculate out averages for each latitudinal band
% discard any cells where any data is not available
if isfinite(gd_co3a(ii,jj,1))
atl_co3_gd(ilat) = atl_co3_gd(ilat) + gd_co3a(ii,jj,1);
c_atl_co3_gd(ilat) = c_atl_co3_gd(ilat) + 1.0;
end;
if isfinite(pred_co3(ii,jj,1))
atl_co3_p1(ilat) = atl_co3_p1(ilat) + pred_co3(ii,jj,1);
c_atl_co3_p1(ilat) = c_atl_co3_p1(ilat) + 1.0;
end;
if isfinite(pred_co3_2(ii,jj,1))
atl_co3_p2(ilat) = atl_co3_p2(ilat) + pred_co3_2(ii,jj,1);
c_atl_co3_p2(ilat) = c_atl_co3_p2(ilat) + 1.0;
end;
if isfinite(woa_sal(ii,jj,1))
atl_sal(ilat) = atl_sal(ilat) + woa_sal(ii,jj,1);
c_atl_sal(ilat) = c_atl_sal(ilat) + 1.0;
end;
or this code:
% calculate averages for each latitudinal band
if (c_co3_gd(ilat) > 5)
co3_gd(ilat) = co3_gd(ilat) / c_co3_gd(ilat);
else
co3_gd(ilat) = NaN;
end;
if (c_co3_pred1(ilat) > 5)
co3_pred1(ilat) = co3_pred1(ilat) / c_co3_pred1(ilat);
else
co3_pred1(ilat) = NaN;
end;
I think that I might need to initialise the original matrices to zeros(181,361) with the data in the first row.
Am I on the right track? Any suggestions would be appreciated.
Many thanks!
Réponse acceptée
Plus de réponses (1)
Fangjun Jiang
le 24 Août 2011
To visualize a series of (x,y,z) data, I made the following example. The first part is just to come up with some data. The second part is the visualization.
Note that the pcolor() in figure 1 has 9x9 patch of colors. The 2-D view of the scatter3() in figure(3) has 10x10 squares of colors. So ignore the first row and last column of figure(3) you will get a 100% match of colors. Adjust the size of the square to achieve the desired results.
close all;
N=10;z=rand(N);
x=repmat(1:N,N,1);
y=repmat((1:N)',1,N);
X=x(:);Y=y(:);Z=z(:);
CircleSize=1500;
figure;pcolor(z);
figure;h1=stem3(X,Y,Z,'filled');
figure;h2=scatter3(X,Y,Z,CircleSize,Z,'s','filled');
view(2);
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!