MATLAB: Confusing Contour and Color Scale Map Results

  • Context: MATLAB 
  • Thread starter Thread starter nenyan
  • Start date Start date
  • Tags Tags
    Confusing Matlab
Click For Summary

Discussion Overview

The discussion revolves around the differences observed when using MATLAB to create contour and color scale maps from an array. Participants explore issues related to data representation and visualization techniques in MATLAB, including the use of functions like contour, image, and imagesc.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes that the results from using the contour and image functions are very different, suggesting a potential issue with how the data is being interpreted.
  • Another participant speculates that MATLAB's image function may be treating the matrix as levels in the range of 0-255 or 63535, which could lead to indistinguishable values if they are too small.
  • A suggestion is made to normalize the data to address the issue, although a later reply indicates that normalization did not resolve the differences.
  • One participant identifies that the y-axis is reversed, which may contribute to the confusion in the visual output.
  • Another participant recommends using the imagesc() function as an alternative, stating that it automatically adjusts the scale range to fit the data.

Areas of Agreement / Disagreement

Participants express differing views on the causes of the discrepancies in the visual outputs, with no consensus reached on a single solution. Some propose normalization while others suggest using imagesc(), and one participant identifies the issue of the reversed y-axis.

Contextual Notes

Participants have not fully explored the implications of using different functions or the specific characteristics of the data being visualized, leaving some assumptions and conditions unaddressed.

nenyan
Messages
67
Reaction score
0
When I use MATLAB to draw contour and color scale map of an array. The result is weird.

my code:
the first:
b=load('c:\...\b.txt');
contour(b)

the second:
b=load('c:\...\b.txt');
image(b)

The results are very different. I upload the array file and two figures.
 

Attachments

  • ri.jpg
    ri.jpg
    8.7 KB · Views: 460
  • le.jpg
    le.jpg
    6.9 KB · Views: 417
  • b.zip
    b.zip
    40.2 KB · Views: 232
Physics news on Phys.org
nenyan said:
When I use MATLAB to draw contour and color scale map of an array. The result is weird.

my code:
the first:
b=load('c:\...\b.txt');
contour(b)

the second:
b=load('c:\...\b.txt');
image(b)

The results are very different. I upload the array file and two figures.
I'm not a Matlab user, so I'm only guessing from the on-line documentation, but it may be that Matlab's image is treating your flat matrix as levels in the range 0-255 (or 63535). In which case, they are all to small to be distinguishable from 0. Try normalizing the data first - I've attached a Mathcad image (zoomed in slightly) to show what I mean (Mathcad converts reals to integers and shows a similar effect, which the function normalize overcomes)
 

Attachments

  • phys - 12 06 20 matlab image 01.JPG
    phys - 12 06 20 matlab image 01.JPG
    23.8 KB · Views: 462
NemoReally said:
I'm not a Matlab user, so I'm only guessing from the on-line documentation, but it may be that Matlab's image is treating your flat matrix as levels in the range 0-255 (or 63535). In which case, they are all to small to be distinguishable from 0. Try normalizing the data first - I've attached a Mathcad image (zoomed in slightly) to show what I mean (Mathcad converts reals to integers and shows a similar effect, which the function normalize overcomes)

Thank you. After nromalization, it is still different.
 

Attachments

  • ri.jpg
    ri.jpg
    18.1 KB · Views: 440
  • le.jpg
    le.jpg
    17.5 KB · Views: 442
Oh, I got it. The y-axis is reversed.
 
You can use the imagesc() function instead of normalization. It will automatically set the scale range to the range of your data.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K