Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab: It is confusing

  1. Jun 19, 2012 #1
    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.
     

    Attached Files:

    • ri.jpg
      ri.jpg
      File size:
      8.7 KB
      Views:
      61
    • le.jpg
      le.jpg
      File size:
      6.9 KB
      Views:
      61
    • b.zip
      b.zip
      File size:
      40.2 KB
      Views:
      51
  2. jcsd
  3. Jun 20, 2012 #2
    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)
     

    Attached Files:

  4. Jun 20, 2012 #3
    Thank you. After nromalization, it is still different.
     

    Attached Files:

    • ri.jpg
      ri.jpg
      File size:
      18.1 KB
      Views:
      49
    • le.jpg
      le.jpg
      File size:
      17.5 KB
      Views:
      49
  5. Jun 20, 2012 #4
    Oh, I got it. The y axis is reversed.
     
  6. Jun 20, 2012 #5
    You can use the imagesc() function instead of normalization. It will automatically set the scale range to the range of your data.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab: It is confusing
  1. MATLAB confusion (Replies: 2)

  2. Confused by Maple (Replies: 2)

  3. Matlab and physics (Replies: 3)

  4. MATLAB problem (Replies: 1)

  5. MATLAB histogram (Replies: 3)

Loading...