Can contourplot plot based on the peaks of the function?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I need to plot a contourplot based on the peaks of my function. I know the maximum of my function but the contourplot maximum is different than that. I need to plot something like the below fig. (the data in 2 figures are not the same)
![q1.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211687/q1.jpeg)
but I get this one in which, the real peak and the contour peak are not the same. Is there any command for edditing this?
![q2.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211688/q2.jpeg)
Thank.
채택된 답변
Cris LaPierre
2019년 4월 3일
편집: Cris LaPierre
2019년 4월 3일
I suspect there is an error in your code. Here's a simple example using the peaks funciton in MATLAB
[x,y,z] = peaks(100);
surf(x,y,z)
view(2)
figure
contour(x,y,z,20)
Here is what the peak function would look like from the top down (view(2))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211751/image.png)
And here is what the corresponding contour plot looks like. Notice that the peaks align.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/211752/image.png)
댓글 수: 8
Cris LaPierre
2019년 4월 4일
I got the values by doing this:
[J,H] = meshgrid(linspace(1.1e13,1.2e13,1000),linspace(14000,14200));
a=P_y(J,H);
I then opened a in the variable editor (double click on it in the workspace).
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!