how to plot with contour this exel file?

2 views (last 30 days)
sara
sara on 31 Aug 2015
Answered: Walter Roberson on 31 Aug 2015
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

Answers (1)

Walter Roberson
Walter Roberson on 31 Aug 2015
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')

Categories

Find more on View and Analyze Simulation Results 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!