Message Boards Message Boards

1
|
5871 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Visualization with ListContourPlot

Posted 9 years ago

Hi everybody,

I'm having some trouble visualizing a function with the ListContourPlot function. I've already done the calcuations and visualization in MATLAB, but need to reproduce the results in Mathematica as well. I've provided a screenshot from MATLAB to show you what I'm aiming for and another screenshot to show you what I'm currently getting in Mathematica.

Calculations are as follows:

linspace[x0_, x1_, n_] := Range[x0, x1, (x1 - x0)/(n - 1)];
Yrange = linspace[-10, 20, 500];
Xrange = linspace[-10, 30, 500];
RErange = 10^(Yrange);
PPLUSrange = 10^(Xrange);
constL = 0.0000346737;
constR = 100000;

z = (1 - (1/RErange)*(PPLUSrange)^0.7*constL)/(1 + (2*pi*RErange/PPLUSrange*constR));

data = Transpose[{Xrange, Yrange, z}];

ListContourPlot[data, Mesh -> None, PlotRange -> {{-10, 30}, {-10, 20}, {0, 1}}, ContourLabels -> All, 
ContourShading -> None, DataRange -> {{-10, 30}, {-10, 20}}]

I'm thinking this is some kind of perspective issue, but I'm not sure.

Any help is greatly appreciated!

Attachments:
POSTED BY: A N
4 Replies

Hello A.N.,

it took me a while to find out what is going wrong here: Your data points do not really fill a plane, but rather lie on a straight line. You can see this with:

Graphics[Point[data[[;; , {1, 2}]]], Frame -> True]

ListContourPlot cannot work that way.

Instead of working with data you can define a analytical function:

constL = 0.0000346737;
constR = 100000;

f[x_, y_] := (1 - (1/(10^y))*(10^x)^0.7*constL)/(1 + (2.*Pi*(10^y)/10^x*constR))

which can be plotted like:

ContourPlot[f[x, y], {x, -10, 30}, {y, -10, 20}, Mesh -> None, 
 ContourLabels -> All, ContourShading -> None, 
 Contours -> Range[.2, 1, .2]]

This gives the result you are expecting!

Henrik

Addendum: I do not want to change your concept. Of course you can work with data values as well:

constL = 0.0000346737;
constR = 100000;
data = Flatten[Table[{x, y, (1 - (1/10^y)*(10^x)^0.7*constL)/(1 + (2*Pi*10^y/10^x*constR))}, {x, -10, 30, .1}, {y, -10, 20, .1}], 1];

ListContourPlot[data, Contours -> Range[.2, 1, .2], ContourLabels -> All, ContourShading -> None]

This also gives the expected result.

POSTED BY: Henrik Schachner

Use "Pi" instead of "pi".

Henrik

POSTED BY: Henrik Schachner
Posted 9 years ago
Attachments:
POSTED BY: A N
Posted 9 years ago

Hi Henrik,

Thank you so much! It works both ways!

With my method I was trying to somehow emulate MATLAB's meshgrid by giving a set of values and getting Mathematica to interpolate the function - I guess I wasn't quite on the right track.

Thanks again! I learned a lot from this!

POSTED BY: A N
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract