Difference between revisions of "MATLAB talk:Plotting Surfaces"
Jump to navigation
Jump to search
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | *I'm having trouble getting contour to plot more than the standard number of contour lines. When I use contour(x, y, z), it plots the contour lines fine, but when I specify the number of lines with contour(x, y, z, n), nothing plots. [[User:Jc257|Jc257]] 23:16, 22 September 2009 (EDT) | |
− | I'm having trouble getting contour to plot more than the standard number of contour lines. When I use contour(x, y, z), it plots the contour lines fine, but when I specify the number of lines with contour(x, y, z, n), nothing plots. [[User:Jc257|Jc257]] 23:16, 22 September 2009 (EDT) | + | *:I have had this same problem. I added a colorbar. When I don't give an "n" argument, the color bar ranges from 0 - 300, the range of the surface plot. When I add an "n" argument, the colorbar ranges from 0 - 1 in 0.1 intervals. If this is so, it makes sense that nothing is graphed, because the surface never gets as low as 1, but why would adding more contour lines change this? (I also tried plotting less contour lines - same thing happens.) [[User:Smc41|Smc41]] 09:39, 23 September 2009 (EDT) |
+ | ** In both cases, the problem is you started with values that make the function go infinite - if you try to use <code>contour</code> with a matrix containing <code>Inf</code>, and then try to specify how many contour lines, MATLAB will become hopelessly confused. Make sure d starts at 1 and theta starts at .1 and you should be able to get multiple contour lines. [[User:DukeEgr93|DukeEgr93]] 13:26, 23 September 2009 (EDT) | ||
− | + | *What's the difference between using a meshgrid and using just two linspaces? (ejl23) | |
− | + | ** Commands like '''meshc''' and '''surfc''' generally want to know the x, y, and z coordinates and those generally need to be in rectangular matrices where the locations of the coordinates tell MATLAB how to "connect the dots." For purely rectilinear grids, there are shortcuts using vector versions of x and y that will work, but generally, the matrix versions are "safer" since they also work for grids created using, say, polar coordinates. [[User:DukeEgr93|DukeEgr93]] 00:23, 8 October 2012 (EDT) |
Latest revision as of 04:23, 8 October 2012
- I'm having trouble getting contour to plot more than the standard number of contour lines. When I use contour(x, y, z), it plots the contour lines fine, but when I specify the number of lines with contour(x, y, z, n), nothing plots. Jc257 23:16, 22 September 2009 (EDT)
- I have had this same problem. I added a colorbar. When I don't give an "n" argument, the color bar ranges from 0 - 300, the range of the surface plot. When I add an "n" argument, the colorbar ranges from 0 - 1 in 0.1 intervals. If this is so, it makes sense that nothing is graphed, because the surface never gets as low as 1, but why would adding more contour lines change this? (I also tried plotting less contour lines - same thing happens.) Smc41 09:39, 23 September 2009 (EDT)
- In both cases, the problem is you started with values that make the function go infinite - if you try to use
contour
with a matrix containingInf
, and then try to specify how many contour lines, MATLAB will become hopelessly confused. Make sure d starts at 1 and theta starts at .1 and you should be able to get multiple contour lines. DukeEgr93 13:26, 23 September 2009 (EDT)
- What's the difference between using a meshgrid and using just two linspaces? (ejl23)
- Commands like meshc and surfc generally want to know the x, y, and z coordinates and those generally need to be in rectangular matrices where the locations of the coordinates tell MATLAB how to "connect the dots." For purely rectilinear grids, there are shortcuts using vector versions of x and y that will work, but generally, the matrix versions are "safer" since they also work for grids created using, say, polar coordinates. DukeEgr93 00:23, 8 October 2012 (EDT)