Visualization with ListContourPlot

Posted 8 years ago
5288 Views
|
4 Replies
|
2 Total Likes
|
 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:
4 Replies
Sort By:
Posted 8 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 8 years ago
 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!HenrikAddendum: 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 8 years ago
 Thank you Henrik! That definitely helped! I'm still not used to Mathematica's case sensitivity.I got a new plot, much closer to that what I need and the values in the "data" array look correct. However, Mathematica still isn't plotting correctly. I've attached a new screenshot of the plot.Interestingly, as I mentioned, the z-values in the array are correct, all being between 0 and 1: data {{-10, -10, 1.53636*10^-6}, {-(4950/499), -(4960/499), 1.60945*10^-6}, {-(4910/499), -(4930/499), 1.68601*10^-6},...,{14890/499, 9920/499, 0.999578}, {14930/499, 9950/499, 0.999584}, \ {30, 20, 0.99959}} However, Mathematica is showing contour values from -5 to 25. I'm not sure if there is something incorrect with the "data" array? Maybe Mathematica is plotting the wrong entries? Z values should be the third entry within each set of {x,y,z} coordinates?Thanks again for the help! Attachments:
Posted 8 years ago