how to plot with contour this exel file?

2 次查看(过去 30 天)
hi I have a question that I couldn't solve this. I have an exel file. the vertical axis is Y and the horizontal axis is X.... and the values in this matrix are Z valuse...for example : if X=ONDb and Y=NCEP then Z=.831
know I want to draw a plot like this:
I know that I should use contour to draw this but my result were not like this image that I attached. can you help me to draw this with contour? any help will be much appreciated

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-31
You cannot draw this kind of plot without assigning numeric coordinate values to each of the X and Y labels. We as on-lookers have no reason to expect that NDJb is not, for example, immediately to the right of NDJa separated by 1/1234'th of the plot width. We as on-lookers would be justified in sorting the labels alphanumerically and using the sort order index as the X or Y coordinate in a scatter plot and do a gridded interpolation in order to fit find a surface to contour.
If you do assign equal-spaced numeric coordinates to the rows and columns in file order, say Xvalues (the columns) and Yvalues (the rows) and corresponding cell array of strings Xlabels and Ylabels (extracted from the file), then
contour(Xvalues, Yvalues, Z);
set(gca, 'XTick', Xvalues, 'XTickLabel', XLabels);
set(gca, 'YTick', Yvalues, 'YTickLabel', YLabels);
colorbar();
If your arbitrary Yvalues for the first data line of the file is numerically lower than your arbitrary Yvalues for the second data line of the file, then you should also add
set(gca, 'YDir', 'reverse')

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by